On Wednesday, September 9, 2020 at 2:58:14 PM UTC-7, Charlie Veniot wrote:
>
> I'm still in the midst of setting up my "Products Review" TiddlyWiki to 
> also behave as a "Urban Off-Gridding for Laypersons" TiddlyWiki.
> Both contexts have much in common (from structural elements to content), 
> and I really did not want to create two distinct TiddlyWikis with a ton of 
> duplication between them.
> Hence the desire to have one TiddlyWiki with two "contextual" appearances.
> Before getting into show and tell images (further below), here are the two 
> links that open the same TiddlyWiki file but trigger different "contextual" 
> appearances upon startup:
>
>    - 
>    https://intertwingularityslicendice.neocities.org/CJ_ProductReviews.html
>    *?context=ProductReviews* 
>    
> <https://intertwingularityslicendice.neocities.org/CJ_ProductReviews.html?context=ProductReviews>
>    - 
>    https://intertwingularityslicendice.neocities.org/CJ_ProductReviews.html
>    *?context=OffGridding* 
>    
> <https://intertwingularityslicendice.neocities.org/CJ_ProductReviews.html?context=OffGridding>
>
> For the moment, only Title and Subtitle change based on context.  Next: I 
> will start modifying other content to change based on context.
>

First... let me congratulate you on a good job of combining many different 
technical bits and pieces!  It shows that you've really dug into the meat 
of TiddlyWiki!  Having said that, I think I can suggest ways to use 
existing TiddlyWiki features to reduce some of the complexities while still 
achieving (nearly) the same results.

Let's start with these two pieces:

>
>    - *GetStartupContext.js*
>    - *Set Startup Context*
>
> The result of these two pieces is to, on startup, get the value of the 
"?context=..." parameter from the URL and save it in a tiddler for later 
use.  However, you are probably not aware that the TWCore already does this 
work for you by automatically creating a set of shadow tiddlers that breaks 
the URL into its component parts:

$:/info/url/full
$:/info/url/host
$:/info/url/hostname
$:/info/url/origin
$:/info/url/pathname
$:/info/url/port
$:/info/url/protocol
$:/info/url/search

For your purposes, you would be most interested in the last one, 
$:/info/url/search.  Given the URLs you show above, this tiddler would 
contain text
?context=ProductReviews
or
?context=OffGridding
Note that the tiddler includes the URL parameter itself, "?context=", not 
just the value.  This is different from your results, but can be easily 
handled later on.

>
>    - *Alternate TiddlyWiki Purposes*
>
> Instead of using a custom field, "purpose", you can just set the value in 
$:/info/url/search, like this:
\define link(suffix)
<a title="Use this link to bookmark this site's purpose." 
href="https://intertwingularityslicendice.neocities.org/CJ_ProductReviews.html?context=$suffix$";
 
style="text-decoration: none;">🔖</a>
\end

<div style="font-size:14px;line-height:1.7;margin-left:30px;color:dimgray;">
<$radio tiddler="$:/info/url/search" value="?context=ProductReviews"> 
{{TiddlyWiki Title 1}} </$radio> <<link "ProductReviews">>
<br>
<$radio tiddler="$:/info/url/search" value="?context=OffGridding"> 
{{TiddlyWiki Title 2}} </$radio> <<link "OffGridding">>
</div>
Notes:
* I retain the existing data value format, including the "?context=" 
prefix.  This keeps the content of $:/info/url/search consistent with the 
value that was automatically set.
* I've turned the inline links (for bookmarking) into a macro definition 
using a parameter for the desired suffix, so that it only need to be 
specified once.

By tagging the above tiddler with *$:/tags/SideBarSegment* and adding a 
field named *list-before*, with a blank value, the radio buttons will 
appear above the title in the sidebar.  This eliminates much of the need 
for the "Fancy TiddlyWiki Title" tiddler.  The rest of that tiddler is 
selecting which title to display, and applying styles to the TiddlyWiki 
title.  This can be achieved directly in the $:/SiteTitle tiddler, like 
this:
<div style="border-top:solid lightgray;">
<div style="font-size:15px;line-height:1.5">Charlie's</div>
<$reveal state="$:/info/url/search" type="match" 
text="?context=ProductReviews">
   {{TiddlyWiki Title 1}}
</$reveal>
<$reveal state="$:/info/url/search" type="match" 
text="?context=OffGridding">
   {{TiddlyWiki Title 2}}
</$reveal>
</div>

Similarly, your conditional subtitle can be achieved directly in the 
$:/SiteSubtitle tiddler, like this:
<div style="color:darkgray;font-size:90%;text-align:right;border-bottom:solid 
lightgray">
   - Version: 
   <$list filter="[!is[system]!has[draft.of]!sort[modified]limit[1]]">
      <$view field="modified" format="date" template="YYYY-0MM-0DD 
0hh12:0mmam" />
   </$list>
   - <br/>
<$reveal state="$:/info/url/search" type="match" 
text="?context=OffGridding">
   <div style="color:gray;border-top:solid lightgray thin;text-align:left;">
      //Easy, practical, and budget-friendly experiments/solutions for 
"light" grid independence.//
   </div>
</$reveal>
</div>
Note that the first part (the version text) is only specified once, and is 
always displayed, regardless of which "mode" you are currently showing,
and the second part (the $reveal) is only displayed when you are showing 
the "OffGridding" mode.

I've probably left out some bits and pieces here and there, but hopefully 
this makes sense to you and you can fill in whatever I've missed without 
too much trouble.

enjoy,
-e

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/0086b077-2c0a-49f7-8fee-99fd71e86c46o%40googlegroups.com.

Reply via email to