Skip to content

Commit 7a4c421

Browse files
committed
addOpenTutorialPage
1 parent 9e38c29 commit 7a4c421

3 files changed

Lines changed: 36 additions & 3 deletions

File tree

Tutorial-o-Matic/history.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
* Added Tutorial-o-Matic How to
1414
* Added command "import Tutorial-o-Matic Styles"
1515
* Added command "Open tutorial page from link"
16+
* Added button that creates a link to current page
17+
* Updated gotoPane to open in corresponding Tab and use withGoBack modifier
18+
* Added openTutorialPage style and pane
1619

1720
## v0.0.5
1821

Tutorial-o-Matic/src/main/groovy/ToM.groovy

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class ToM{
4343
openMap : 'ToM_openMap' ,
4444
openTutMap: 'ToM_openTutMap',
4545
showNode : 'ToM_showNode' ,
46+
openTutorialPage : 'ToM_openTutPage',
4647
]
4748

4849
static final exeHowIcons = ['emoji-1F507', 'emoji-2328', 'emoji-1F5B1']
@@ -125,6 +126,9 @@ class ToM{
125126
case styles.goto:
126127
addGotoPane(myPanel, tutNode, nextTutNodes[0], options)
127128
break
129+
case styles.openTutorialPage:
130+
addOpenTutorialPage(myPanel, tutNode, options)
131+
break
128132
case styles.action:
129133
addActionPane(myPanel, tutNode, options)
130134
break
@@ -323,6 +327,20 @@ class ToM{
323327
def buttonPanel = tomui.createButtonPanel(msgHtml,bttnText,bttnToolTip, bttnAction, false)
324328
myP.add(buttonPanel, tomui.GBC)
325329
}
330+
331+
def static addOpenTutorialPage(myP, ApiNode tNode, options){
332+
def nodos = tNode.children.findAll{ n -> isValidUri(n.link?.uri) || isValidUri(n[attributeNewPageLink].uri)}
333+
nodos.each{nodo ->
334+
def msgHtml = nodo.note?tomui.getHtmlFromNote(nodo, options):null
335+
def bttnText = nodo.text
336+
def bttnToolTip = "Click to go to '${bttnText}' section"
337+
def bttnAction = { e ->
338+
openTutorialPage(nodo)
339+
}
340+
def buttonPanel = tomui.createButtonPanel(msgHtml, bttnText, bttnToolTip, bttnAction, false)
341+
myP.add(buttonPanel, tomui.GBC)
342+
}
343+
}
326344

327345
def static addGroovyPane(myP, ApiNode nodoT){
328346
def parentEnabled = !disableBttn(nodoT)
@@ -673,20 +691,27 @@ class ToM{
673691

674692
def static openTutorialPageUri(URI uri, ApiMindMap mapa){
675693
// if(!uri) return null
676-
def isMindmap = uri.scheme in ['file','tutorial'] && uri.path.endsWith('.mm')
677-
def nodeId = (!uri.scheme || isMindmap) && uri.fragment?.startsWith('ID_')?
694+
def isMM = isMindmap(uri)
695+
def nodeId = (!uri.scheme || isMM) && uri.fragment?.startsWith('ID_')?
678696
uri.fragment
679697
: null
680698
// if (!nodeId) return 'No node ID defined in URI'
681-
def tutMapPath = /* nodeId && */ isMindmap ?
699+
def tutMapPath = /* nodeId && */ isMM ?
682700
uri.path.drop(1)
683701
:null
684702
def tutMap = tutMapPath ?
685703
getMapFromPath(tutMapPath, false) //open mind map not visible
686704
: mapa
687705
openTutorialPageString(nodeId, tutMap)
688706
}
707+
708+
def static isMindmap(uri){
709+
uri && uri.scheme in ['file','tutorial'] && uri.path.endsWith('.mm')
710+
}
689711

712+
def static isValidUri(uri){
713+
return uri && (!uri.scheme && uri.fragment?.startsWith('ID_') || isMindmap(uri))
714+
}
690715

691716
def static openTutorialPageString(String nodeId, ApiMindMap tutMap){
692717
if(!tutMap) return 'No tutorial mindmap defined'

Tutorial-o-Matic/zips/templates/Tutorial-o-Matic/tutorial_styles_template.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@
110110
<icon BUILTIN="emoji-1F517"/>
111111
<cloud COLOR="#f9f9b9" SHAPE="ROUND_RECT"/>
112112
</stylenode>
113+
<stylenode TEXT="ToM_openTutPage" ID="ID_590356041" ICON_SIZE="16 pt" STYLE="rectangle" BORDER_WIDTH="3 px">
114+
<icon BUILTIN="emoji-1F989"/>
115+
<icon BUILTIN="emoji-1F4D6"/>
116+
<cloud COLOR="#f9f9b9" SHAPE="ROUND_RECT"/>
117+
</stylenode>
113118
</stylenode>
114119
<stylenode LOCALIZED_TEXT="styles.AutomaticLayout" POSITION="right" STYLE="bubble">
115120
<stylenode LOCALIZED_TEXT="AutomaticLayout.level.root" ID="ID_1618325545" COLOR="#000000" STYLE="bubble" SHAPE_HORIZONTAL_MARGIN="5 pt" SHAPE_VERTICAL_MARGIN="10 pt" UNIFORM_SHAPE="true" MAX_WIDTH="4 cm" MIN_WIDTH="1 cm">

0 commit comments

Comments
 (0)