Creating Lepiter UI for hedgedoc url import and improving hedgedoc url test.
This commit is contained in:
parent
06ccc84c29
commit
b518ec0c7c
@ -122,6 +122,14 @@ HedgeDoc >> url [
|
|||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
HedgeDoc >> url: anObject [
|
HedgeDoc >> url: anObject [
|
||||||
|
| tempUrl html |
|
||||||
|
tempUrl := anObject asZnUrl.
|
||||||
|
html := XMLHTMLParser parse: tempUrl retrieveContents.
|
||||||
|
(html xpath: '//head/meta[@name="application-name"][@content = "HedgeDoc - Ideas grow better together"]') isEmpty
|
||||||
|
ifTrue: [ self inform: 'Not a hedgedoc url'.
|
||||||
|
url := nil ].
|
||||||
|
self metadata at: 'title' put: tempUrl firstPathSegment.
|
||||||
|
server := tempUrl host.
|
||||||
url := anObject
|
url := anObject
|
||||||
]
|
]
|
||||||
|
|
||||||
|
57
src/MiniDocs/LeHomeDatabaseHeaderElement.extension.st
Normal file
57
src/MiniDocs/LeHomeDatabaseHeaderElement.extension.st
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
Extension { #name : #LeHomeDatabaseHeaderElement }
|
||||||
|
|
||||||
|
{ #category : #'*MiniDocs' }
|
||||||
|
LeHomeDatabaseHeaderElement >> importMinidocsButtonElement [
|
||||||
|
^ self userData at: 'importMinidocsButtonElement' ifAbsentPut: [ self newImportMiniDocsButton]
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #'*MiniDocs' }
|
||||||
|
LeHomeDatabaseHeaderElement >> initialize [
|
||||||
|
super initialize.
|
||||||
|
self initializeEditableTitleElement.
|
||||||
|
self initializeButtons.
|
||||||
|
|
||||||
|
self addChild: self toolbarElement as: #toolbar.
|
||||||
|
self toolbarElement
|
||||||
|
addItem: self editableTitleElement;
|
||||||
|
addItem: self newAddNewPageButton;
|
||||||
|
addItem: self removeButtonElement;
|
||||||
|
addItem: self importButtonElement;
|
||||||
|
addItem: self exportButtonElement;
|
||||||
|
addItem: self importMinidocsButtonElement.
|
||||||
|
|
||||||
|
self addAptitude: (BrLayoutResizerAptitude new
|
||||||
|
hInherit;
|
||||||
|
vAnyToFitContent;
|
||||||
|
hInherit: self toolbarElement;
|
||||||
|
vAnyToFitContent: self toolbarElement).
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #'*MiniDocs' }
|
||||||
|
LeHomeDatabaseHeaderElement >> initializeButtons [
|
||||||
|
self initializeRemoveButton.
|
||||||
|
self initializeImportButton.
|
||||||
|
self initializeExportButton.
|
||||||
|
self initializeMiniDocsImportButton.
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #'*MiniDocs' }
|
||||||
|
LeHomeDatabaseHeaderElement >> initializeMiniDocsImportButton [
|
||||||
|
"importMinidocsButtonElement := self newImportMiniDocsButton."
|
||||||
|
self userData at: 'importMinidocsButtonElement' put: self newImportMiniDocsButton.
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #'*MiniDocs' }
|
||||||
|
LeHomeDatabaseHeaderElement >> newImportMiniDocsButton [
|
||||||
|
^ LeMiniDocsImport new
|
||||||
|
tooltip: 'Import MiniDocs from url';
|
||||||
|
contentExtent: 200 @ 30
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #'*MiniDocs' }
|
||||||
|
LeHomeDatabaseHeaderElement >> updateToolbarButtons [
|
||||||
|
self updateRemoveButtonElement.
|
||||||
|
self exportButtonElement database: self database.
|
||||||
|
self importButtonElement database: self database.
|
||||||
|
self importMinidocsButtonElement database: self database.
|
||||||
|
]
|
89
src/MiniDocs/LeMiniDocsImport.class.st
Normal file
89
src/MiniDocs/LeMiniDocsImport.class.st
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
Class {
|
||||||
|
#name : #LeMiniDocsImport,
|
||||||
|
#superclass : #BrButton,
|
||||||
|
#instVars : [
|
||||||
|
'contentExtent',
|
||||||
|
'database'
|
||||||
|
],
|
||||||
|
#category : #'MiniDocs-UI'
|
||||||
|
}
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
LeMiniDocsImport >> contentExtent [
|
||||||
|
^ contentExtent
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
LeMiniDocsImport >> contentExtent: aPoint [
|
||||||
|
self
|
||||||
|
assert: [ aPoint isNotNil ]
|
||||||
|
description: [ 'Extent must be non-nil' ].
|
||||||
|
contentExtent := aPoint
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
LeMiniDocsImport >> createDropdownExpandedHandleButton [
|
||||||
|
^ BrButton new
|
||||||
|
icon: BrGlamorousVectorIcons downwards;
|
||||||
|
label: self tooltip;
|
||||||
|
aptitude: BrGlamorousButtonWithIconAndLabelAptitude
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
LeMiniDocsImport >> createURLeditable [
|
||||||
|
| base editable |
|
||||||
|
base := BlElement new
|
||||||
|
background: (Color white);
|
||||||
|
size: 200 @ 30;
|
||||||
|
margin: (BlInsets all: 10);
|
||||||
|
yourself.
|
||||||
|
editable := BrEditableLabel new
|
||||||
|
aptitude: BrGlamorousEditableLabelAptitude new glamorousRegularFontAndSize;
|
||||||
|
text: 'Hedgedoc url';
|
||||||
|
switchToEditor.
|
||||||
|
editable when: BrEditorAcceptWish do: [ :aWish |
|
||||||
|
self importHedgedoc: aWish text asString.
|
||||||
|
].
|
||||||
|
base addChild: editable.
|
||||||
|
^ base
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
LeMiniDocsImport >> database: aLeDatabase [
|
||||||
|
database := aLeDatabase
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
LeMiniDocsImport >> importHedgedoc: aURL [
|
||||||
|
| doc text page |
|
||||||
|
doc := HedgeDoc new url: aURL asString.
|
||||||
|
text := doc retrieveContents; contents.
|
||||||
|
page := LePage named: (doc metadata at: 'title').
|
||||||
|
page addSnippet: (LeTextSnippet string: text).
|
||||||
|
^ database addPage: page
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
LeMiniDocsImport >> initialize [
|
||||||
|
super initialize.
|
||||||
|
|
||||||
|
self
|
||||||
|
icon: BrGlamorousVectorIcons downwards;
|
||||||
|
label: 'Add MiniDocs';
|
||||||
|
aptitude: BrGlamorousButtonWithIconAndLabelAptitude.
|
||||||
|
self addAptitude: (BrGlamorousWithDropdownAptitude
|
||||||
|
handle: [ self createDropdownExpandedHandleButton ]
|
||||||
|
content: [ self createURLeditable ]).
|
||||||
|
|
||||||
|
self aptitude - BrGlamorousButtonExteriorAptitude.
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
LeMiniDocsImport >> tooltip [
|
||||||
|
^ self label
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
LeMiniDocsImport >> tooltip: aString [
|
||||||
|
self label: aString
|
||||||
|
]
|
@ -26,8 +26,3 @@ PPCMInlinedCode >> code: anObject [
|
|||||||
PPCMInlinedCode >> text [
|
PPCMInlinedCode >> text [
|
||||||
^ code
|
^ code
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
|
||||||
PPCMInlinedCode >> viewBody [
|
|
||||||
^ (self className ,' ', self text) asRopedText.
|
|
||||||
]
|
|
||||||
|
Loading…
Reference in New Issue
Block a user