Eric:

"Very nice" code that is Functional, and Educational.

Thank you very much for yet another in a long list of contributions!

Cheers,
Hans

On Friday, July 24, 2020 at 12:45:16 PM UTC-4 Eric Shulman wrote:

> On Friday, July 24, 2020 at 3:34:52 AM UTC-7, Felicia Crow wrote:
>>
>> so after playing around with filter operators and trying to find a way 
>> over a data tiddler I wrote a javascript macro I attatched below.
>> The only caveat with this is that you have to close and reopen the 
>> tiddler calling the macro due to how javascript macros are called. Maybe 
>> someone has an idea for how to reload a single tiddler.
>>
>
> Here's a version that does the same results using just wikitext instead of 
> javascript:
> \define getData()
> <$list filter="[all[missing]!has[draft.of]sort[title]]">
>    <$text text="[["/>{{{ 
> [<currentTiddler>backlinks[]count[]divide[1000]removeprefix[0.]] 
> }}};<<currentTiddler>><$text text="]]"/><br>
> </$list>
> \end
>
> \define renderTable()
> <table>
> <tr><th>Missing</th><th>Times Referenced</th></tr>
> <$list filter="[enlist<missing>!sort[]]">
>    <tr>
>    <td>{{{ [<currentTiddler>split[;]rest[]join[;]] }}}</td>
>    <td style="text-align:right;"><$text text={{{ 
> [<currentTiddler>split[;]first[]divide[1]] }}}/></td>
>    </tr>
> </$list>
> </table>
> \end
>
> \define renderList()
> <ul>
> <$list filter="[enlist<missing>!sort[]]">
>    <li> {{{ [<currentTiddler>split[;]rest[]join[;]] }}} (<$text text={{{ 
> [<currentTiddler>split[;]first[]divide[1]] }}}/>)</li>
> </$list>
> </ul>
> \end
>
> <$list filter="[all[missing]limit[1]]" variable="has_missing_tiddlers"
>    emptyMessage="<p>No Missing Tiddlers</p>">
>    <$wikify name="missing" text=<<getData>>>
>    <<renderList>>
>    </$wikify>
> </$list>
>
> I patterned the code structure similar to your javascript code.
>
> * the outermost $list checks that there are missing tiddlesr and displays 
> either "No Missing Tiddlers", or proceed to get the list of missing 
> tiddlers and show the output
> * getData() generates a list all missing tiddlers
> * each item in the list is a combination of the backlinks[]count[] 
> (zero-padded) and the missing tiddler title, separated by a semi-colon and 
> enclosed in doubled square brackets (to handle spaces in titles)
> * the results of getData() are passed through $wikify to convert the macro 
> output into an actual list of items
> * renderList() and renderTable() enlist[] all items, sorted in descending 
> order using the zero-padded count, and then splits each item back into its 
> title and count and then shows the title followed by the count
>
> 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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/601789af-b470-4a5b-a3fb-10b8afeecdc2n%40googlegroups.com.

Reply via email to