1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-24 22:33:16 +00:00

Text-slicer: better static HTML generation

This commit is contained in:
Jermolene 2015-09-11 13:33:58 +01:00
parent c20e5b47b6
commit b379ab4f87
16 changed files with 121 additions and 31 deletions

View File

@ -16,6 +16,10 @@ Dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
@@
!! What's with all the < angle brackets
An opportunity to see how characters that need HTML encoding (like < angle brackets) are dealt with.
!!! Who uses TiddlyWiki?
@@.intro

View File

@ -142,7 +142,7 @@ Slicer.prototype.processNodeList = function(domNodeList) {
Slicer.prototype.processNode = function(domNode) {
var title, parentTitle, tags,
text = domNode.textContent,
text = $tw.utils.htmlEncode(domNode.textContent),
nodeType = domNode.nodeType;
if(nodeType === 1) { // DOM element nodes
var tagName = domNode.tagName.toLowerCase();

View File

@ -20,7 +20,7 @@ $(tv-heading-status-config-title)$/$(tv-heading-status-config-prefix)$/$(current
</$reveal>
</div>
<$link tag="$level$" class="tc-document-tiddler-link">
<$view field="text"/>
<$transclude/>
</$link>
<$reveal type="nomatch" state=<<tv-heading-status-config-title>> text="open" default=<<tv-default-heading-state>>>
<$list filter="[list<currentTiddler>!has[draft.of]]" template="$:/plugins/tiddlywiki/text-slicer/templates/interactive/tiddler"/>

View File

@ -0,0 +1,7 @@
title: $:/plugins/tiddlywiki/text-slicer/templates/plain/document
<$set name="tv-exclude-filter" value={{!!toc-exclude-filter}}>
<$list filter="[list<currentTiddler>!has[draft.of]]" template="$:/plugins/tiddlywiki/text-slicer/templates/plain/tiddler"/>
</$set>

View File

@ -0,0 +1,10 @@
title: $:/plugins/tiddlywiki/text-slicer/templates/plain/heading
\define body(level:"h1")
<$level$>
<$transclude/>
</$level$>
<$list filter="[list<currentTiddler>!has[draft.of]]" template="$:/plugins/tiddlywiki/text-slicer/templates/plain/tiddler"/>
\end
<$macrocall $name="body" level={{!!toc-heading-level}}/>

View File

@ -0,0 +1,11 @@
title: $:/plugins/tiddlywiki/text-slicer/templates/plain/item
\define body()
<li>
<$transclude/>
</li>
\end
<<body>>

View File

@ -0,0 +1,11 @@
title: $:/plugins/tiddlywiki/text-slicer/templates/plain/list
\define body(type:"ul")
<$type$>
<$list filter="""[all[current]] $(tv-exclude-filter)$ +[limit[1]]""" variable="item">
<$list filter={{!!toc-list-filter}} template="$:/plugins/tiddlywiki/text-slicer/templates/plain/tiddler"/>
</$list>
</$type$>
\end
<$macrocall $name="body" type={{!!toc-list-type}}/>

View File

@ -0,0 +1,15 @@
title: $:/plugins/tiddlywiki/text-slicer/templates/plain/paragraph
\define body()
<div>
<$list filter="""[all[current]] $(tv-exclude-filter)$ +[limit[1]]""" variable="item">
<$transclude/>
</$list>
</div>
\end
<<body>>

View File

@ -0,0 +1,25 @@
title: $:/plugins/tiddlywiki/text-slicer/templates/plain/tiddler
<$vars toc-type={{!!toc-type}}>
<$list filter="[<toc-type>prefix[document]]" variable="item">
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/plain/document" mode="block"/>
</$list>
<$list filter="[<toc-type>prefix[heading]]" variable="item">
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/plain/heading" mode="block"/>
</$list>
<$list filter="[<toc-type>prefix[paragraph]]" variable="item">
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/plain/paragraph" mode="block"/>
</$list>
<$list filter="[<toc-type>prefix[list]]" variable="item">
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/plain/list" mode="block"/>
</$list>
<$list filter="[<toc-type>prefix[item]]" variable="item">
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/plain/item" mode="block"/>
</$list>
</$vars>

View File

@ -1,7 +1,11 @@
title: $:/plugins/tiddlywiki/text-slicer/templates/static/document
`<div class="tc-output-document">`
<$set name="tv-exclude-filter" value={{!!toc-exclude-filter}}>
<$list filter="[list<currentTiddler>!has[draft.of]]" template="$:/plugins/tiddlywiki/text-slicer/templates/static/tiddler"/>
</$set>
`</div>`

View File

@ -1,10 +1,9 @@
title: $:/plugins/tiddlywiki/text-slicer/templates/static/heading
\define body(level:"h1")
<$level$>
<$view field="text"/>
</$level$>
<$list filter="[list<currentTiddler>!has[draft.of]]" template="$:/plugins/tiddlywiki/text-slicer/templates/static/tiddler"/>
\end
`<`<$text text={{!!toc-heading-level}}/>`>`
<$macrocall $name="body" level={{!!toc-heading-level}}/>
<$view field="text" format="htmlencodedplainwikified"/>
`</`<$text text={{!!toc-heading-level}}/>`>`
<$list filter="[list<currentTiddler>!has[draft.of]]" template="$:/plugins/tiddlywiki/text-slicer/templates/static/tiddler"/>

View File

@ -1,11 +1,9 @@
title: $:/plugins/tiddlywiki/text-slicer/templates/static/item
\define body()
<li class="tc-document-tiddler-link">
`<li>`
<$transclude/>
</li>
\end
`</li>`
<<body>>
<$list filter="[list<currentTiddler>!has[draft.of]]" template="$:/plugins/tiddlywiki/text-slicer/templates/static/tiddler"/>

View File

@ -1,11 +1,11 @@
title: $:/plugins/tiddlywiki/text-slicer/templates/static/list
\define body(type:"ul")
<$type$>
<$list filter="""[all[current]] $(tv-exclude-filter)$ +[limit[1]]""" variable="item">
<$list filter={{!!toc-list-filter}} template="$:/plugins/tiddlywiki/text-slicer/templates/static/tiddler"/>
</$list>
</$type$>
\end
<$macrocall $name="body" type={{!!toc-list-type}}/>
`<`<$text text={{!!toc-list-type}}/>`>`
<$list filter={{!!toc-list-filter}} template="$:/plugins/tiddlywiki/text-slicer/templates/static/tiddler"/>
`</`<$text text={{!!toc-list-type}}/>`>`
</$list>

View File

@ -1,15 +1,11 @@
title: $:/plugins/tiddlywiki/text-slicer/templates/static/paragraph
\define body()
<div class="tc-document-tiddler-link">
<$list filter="""[all[current]] $(tv-exclude-filter)$ +[limit[1]]""" variable="item">
<$transclude/>
`<p>`
<$view field="text" format="htmlencodedplainwikified"/>
`</p>`
</$list>
</div>
\end
<<body>>

View File

@ -3,23 +3,33 @@ title: $:/plugins/tiddlywiki/text-slicer/templates/static/tiddler
<$vars toc-type={{!!toc-type}}>
<$list filter="[<toc-type>prefix[document]]" variable="item">
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/static/document" mode="block"/>
</$list>
<$list filter="[<toc-type>prefix[heading]]" variable="item">
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/static/heading" mode="block"/>
</$list>
<$list filter="[<toc-type>prefix[paragraph]]" variable="item">
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/static/paragraph" mode="block"/>
</$list>
<$list filter="[<toc-type>prefix[list]]" variable="item">
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/static/list" mode="block"/>
</$list>
<$list filter="[<toc-type>prefix[item]]" variable="item">
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/static/item" mode="block"/>
</$list>
</$vars>

View File

@ -9,7 +9,7 @@ title: $:/plugins/tiddlywiki/text-slicer/ui/document/header
<$checkbox tiddler=<<config-show-toolbar>> field="text" checked="yes" unchecked="no" default="no"> Show toolbar</$checkbox>
<$button>
<$action-sendmessage $message="tm-open-window" $param=<<currentTiddler>> template="$:/plugins/tiddlywiki/text-slicer/templates/static/document" output="text/html"/>
<$action-sendmessage $message="tm-open-window" $param=<<currentTiddler>> template="$:/plugins/tiddlywiki/text-slicer/templates/plain/document"/>
View document
</$button>