Hi Jeremy, Would the syntax use line breaks? Or were you thinking about all on one line? How do line breaks work with wikitext like that?
--Arlen On Thu, Mar 20, 2014 at 1:16 PM, Jeremy Ruston <[email protected]>wrote: > Hi Arlen > > Good stuff. My intention is to do something very similar but for the > literal tiddler syntax to resemble a .tid file: > > title: myTitle > tags: one two three > text: This is the text > > I was primarily thinking about using the syntax with the new tiddler > message, but it's a good idea to support it on the fieldmangler widget as > well. > > Best wishes > > Jeremy > > > > > > On Thu, Mar 20, 2014 at 1:22 PM, Arlen Beiler <[email protected]> wrote: > >> Hi Everyone, >> Here is the result of my latest endeavor. This adds a create parameter to >> the fieldmangler widget which creates the tiddler specified in "tiddler" >> with the fields in "create". This allows temp tiddlers to be initialized >> with state data without needing a button click. Notice that it only creates >> it if it doesn't exist. >> >> this.mangleTitle = ... ; //Insert after this line in execute() >> this.createText = this.getAttribute("create",false); >> if(typeof(this.createText) === "string") { >> try{ this.createText = JSON.parse(this.createText); } >> catch (e) { console.error(e); this.createText = false; } >> console.log(this.createText); >> if(this.createText){ >> this.createText['title'] = this.mangleTitle; >> if(!this.wiki.tiddlerExists(this.mangleTitle)) >> this.wiki.addTiddler(this.createText); >> } >> } >> >> And here is a tiddler that uses it. This tiddler creates a button that >> toggles the story river between centered and normal. Centered is default. >> >> \define createStateTiddler() >> { "text": "$(default)$" , "tags": "$:/tags/stylesheet" } >> \end >> \define state-1-css() >> >> \end >> \define state-2-css() >> @media (min-width: 770px) { .story-river { margin: 0 auto; } >> .sidebar-header { left: 50%; right: 0; padding-left: 413px; } } >> \end >> <$set name="default" value=<<state-2-css>> > >> <span title="Toggle width/sidebar"> >> <$fieldmangler tiddler="$:/temp/toggle-centered" >> create=<<createStateTiddler>>> >> <$reveal type="match" state="$:/temp/toggle-centered" >> text=<<state-1-css>> default=$(default)$> >> <$button message="tw-add-tag" param="$:/tags/stylesheet" >> set="$:/temp/toggle-centered" setTo=<<state-2-css>> class="btn-invisible >> centered-toggle-1">{{$:/_images/right-arrow-button}}</$button> >> </$reveal><$reveal type="match" state="$:/temp/toggle-centered" >> text=<<state-2-css>>> >> <$button message="tw-add-tag" param="$:/tags/stylesheet" >> set="$:/temp/toggle-centered" setTo=<<state-1-css>> class="btn-invisible >> centered-toggle-2">{{$:/_images/left-arrow-button}}</$button> >> </$reveal></$fieldmangler> >> </span> >> </$set> >> >> If you don't have the corresponding images for the buttons, just remove >> the btn-invisible class from the buttons. I'm putting this out as a feature >> request (a hackability request?). >> >> I haven't changed the buttons yet, so that is how they were working >> before I did this. I had to click the button once to create the tiddler, >> and then a second time to finally see something happen. This way, whatever >> way I initialize it I see the effect on start up. >> >> Is this something that could be added to the core? Note that "create", as >> I wrote it, must be valid JSON and the title gets overwritten if it is >> there. Enjoy! >> >> --Arlen >> >> -- >> You received this message because you are subscribed to the Google Groups >> "TiddlyWikiDev" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/tiddlywikidev. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Jeremy Ruston > mailto:[email protected] > > -- > You received this message because you are subscribed to the Google Groups > "TiddlyWikiDev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/tiddlywikidev. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/tiddlywikidev. For more options, visit https://groups.google.com/d/optout.
