Tiddlywiki. TiddlyTools. TagCloud for specific tags only - tiddlywiki

I just found a great tool for TagCloud generating - https://tiddlytools.com/filtergenerators.html#TiddlyTools%2FFilterGenerators%2FTagCloud
Could you please help me out to change the code for showing only specific tags (For Example: just "TiddlyTools" and "$:/tags/ControlPanel" without others tags)?
\define config() $:/config/TiddlyTools/TagCloud
\define tag-pill-styles() ---------- copied from $:/core/macros/tag - use $(count)$ to set font-size
\define tag-pill-styles()
background-color:$(backgroundColor)$;
fill:$(foregroundColor)$;
color:$(foregroundColor)$;
font-size:calc(0.5em + (0.2em * ($(count)$ / 5) ) );
\end
\define tag-pill-inner() ---------- copied from $:/core/macros/tag - added $(count)$ display in pill
\define tag-pill-inner(tag,icon,colour,fallbackTarget,colourA,colourB,element-tag,element-attributes,actions)
<$vars foregroundColor=<<contrastcolour target:"""$colour$""" fallbackTarget:"""$fallbackTarget$""" colourA:"""$colourA$""" colourB:"""$colourB$""">> backgroundColor="""$colour$""">
<$element-tag$ $element-attributes$ class="tc-tag-label tc-btn-invisible" style=<<tag-pill-styles>>>
$actions$<$transclude tiddler="""$icon$"""/> <$view tiddler=<<__tag__>> field="title" format="text" /> ($(count)$)
</$element-tag$>
</$vars>
\end
\define tagcloud_get()
<$list filter="[all[tiddlers+shadows]tags[]]">
<$text text="[["/>{{{ [<currentTiddler>tagging[]count[]divide[10000]] }}};<<currentTiddler>><$text text="]]"/>
</$list>
\end
\define tagcloud_sort()
<$list filter="[enlist<items>!nsort[]]">
<$list filter="[<currentTiddler>split[;]last[]]"><$text text="[["/><<currentTiddler>><$text text="]]"/></$list>
</$list>
\end
\define tagcloud_showbycount()
<$wikify name="items" text=<<tagcloud_get>> >
<$wikify name="sorted" text=<<tagcloud_sort>> >
<$list filter=<<sorted>>>
<$vars count={{{ [<currentTiddler>tagging[]count[]] }}}>
<<tag>>
</$vars>
</$list>
</$wikify>
</$wikify>
\end
\define tagcloud_showbyname()
<$list filter="[all[tiddlers+shadows]tags[]sort[]]">
<$vars count={{{ [<currentTiddler>tagging[]count[]] }}}>
<<tag>>
</$vars>
</$list>
\end
<style> .tt-tagcloud input { width:auto !important; } </style>
<div class="tt-tagcloud">
There are ''<$text text={{{ [all[tiddlers+shadows]tags[]count[]]" }}}/> tags''
and a total of ''<$text text={{{ [all[tiddlers+shadows]tags[]tagging[]count[]]" }}}/>
tagged tiddlers''<br>
sort by:
<$radio tiddler=<<config>> field="sortorder" value="count"> tagging count </$radio>
<$radio tiddler=<<config>> field="sortorder" value="name"> tag name </$radio>
<p>
<$reveal default={{{ [<config>get[sortorder]] ~[[count]] }}} type="match" text="count"> <<tagcloud_showbycount>> </$reveal>
<$reveal default={{{ [<config>get[sortorder]] }}} type="match" text="name"> <<tagcloud_showbyname>> </$reveal>
</p>

Eric Shulman, the author of TiddlyTools, has updated the code. Thanks again, Eric!
\define config() $:/config/TiddlyTools/TagCloud
\define tag-pill-styles() ---------- copied from $:/core/macros/tag - use $(count)$ to set font-size
\define tag-pill-styles()
background-color:$(backgroundColor)$;
fill:$(foregroundColor)$;
color:$(foregroundColor)$;
font-size:calc(0.5em + (0.2em * ($(count)$ / 5) ) );
\end
\define tag-pill-inner() ---------- copied from $:/core/macros/tag - added $(count)$ display in pill
\define tag-pill-inner(tag,icon,colour,fallbackTarget,colourA,colourB,element-tag,element-attributes,actions)
<$vars foregroundColor=<<contrastcolour target:"""$colour$""" fallbackTarget:"""$fallbackTarget$""" colourA:"""$colourA$""" colourB:"""$colourB$""">> backgroundColor="""$colour$""">
<$element-tag$ $element-attributes$ class="tc-tag-label tc-btn-invisible" style=<<tag-pill-styles>>>
$actions$<$transclude tiddler="""$icon$"""/> <$view tiddler=<<__tag__>> field="title" format="text" /> ($(count)$)
</$element-tag$>
</$vars>
\end
\define tagcloud_get()
<$list filter="[<config>get[taglist]enlist-input[]]">
<$text text="[["/>{{{ [<currentTiddler>tagging[]count[]divide[10000]] }}};<<currentTiddler>><$text text="]]"/>
</$list>
\end
\define tagcloud_sort()
<$list filter="[enlist<items>!nsort[]]">
<$list filter="[<currentTiddler>split[;]last[]]"><$text text="[["/><<currentTiddler>><$text text="]]"/></$list>
</$list>
\end
\define tagcloud_showbycount()
<$wikify name="items" text=<<tagcloud_get>> >
<$wikify name="sorted" text=<<tagcloud_sort>> >
<$list filter=<<sorted>>>
<$vars count={{{ [<currentTiddler>tagging[]count[]] }}}>
<<tag>>
</$vars>
</$list>
</$wikify>
</$wikify>
\end
\define tagcloud_showbyname()
<$list filter="[<config>get[taglist]enlist-input[]sort[]]">
<$vars count={{{ [<currentTiddler>tagging[]count[]] }}}>
<<tag>>
</$vars>
</$list>
\end
<style> .tt-tagcloud input { width:auto !important; } </style>
<div class="tt-tagcloud">
Select tags:
<$button>none
<$action-setfield $tiddler=<<config>> taglist="" />
</$button>
<$button>all
<$set name="taglist" filter="[all[tiddlers+shadows]tags[]sort[]]">
<$action-setfield $tiddler=<<config>> taglist=<<taglist>> />
</$set>
</$button><br>
<div style="display:inline-block;float:left;margin-right:1em;margin-bottom:1em;">
<$select tiddler=<<config>> field="taglist" multiple>
<$list filter="[all[tiddlers+shadows]tags[]sort[]]"><option><<currentTiddler>></option></$list>
</$select>
</div>
<br>
There are ''<$text text={{{ [<config>get[taglist]enlist-input[]count[]]" }}}/> selected tags''
tagging a total of ''<$text text={{{ [<config>get[taglist]enlist-input[]tagging[]count[]]" }}}/> tiddlers''<br>
Sort results by:
<$radio tiddler=<<config>> field="sortorder" value="count"> count </$radio>
<$radio tiddler=<<config>> field="sortorder" value="name"> name </$radio>
<p style="clear:both;">
<$reveal default={{{ [<config>get[sortorder]] ~[[count]] }}} type="match" text="count"> <<tagcloud_showbycount>> </$reveal>
<$reveal default={{{ [<config>get[sortorder]] }}} type="match" text="name"> <<tagcloud_showbyname>> </$reveal>
</p>

Related

Sphinx anchor defined twice (singlehtml output)

I have a sphinx project which uses figures and footnotes. I noticed that as soon as I include a caption in figures, the ids rendered in HTML are defined twice.
For example, consider a minimal project like this:
Project Example
===============
this is index.rst
.. toctree::
:maxdepth: 2
:caption: Contents:
inc
hello [#0]_ world:
We should expect that footnote 0 [#1]_ would have `id1`, and footnote 2 `id2`
.. [#0] Lorem Impsum.
.. [#1] Lorem Impsum.
And inc.rst:
Included
========
.. figure:: _static/cat.jpg
:scale: 20%
:align: center
This is a caption
Running sphinx-build -M singlehtml "." "_build" renders:
<span id="document-inc"></span><section id="included">
<h2>Included<a class="headerlink" href="#included" title="Permalink to this headline">¶</a></h2>
<figure class="align-center" id="id1">
<a ...></a>
<figcaption>
<p><span class="caption-text">This is a caption</span><a class="headerlink" href="#id1" title="Permalink to this image">¶</a></p>
</figcaption>
</figure>
</section>
</div>
<p>We should expect that operator <a class="footnote-reference brackets" href="#id3" id="id1">2</a> would:</p>
<p>We should expect that operator <a class="footnote-reference brackets" href="#id4" id="id2">3</a> would:</p>
<dl class="footnote brackets">
<dt class="label" id="id3"><span class="brackets"><a class="fn-backref" href="#id1">2</a></span></dt>
<dd><p>Lorem Impsum.</p>
</dd>
<dt class="label" id="id4"><span class="brackets"><a class="fn-backref" href="#id2">3</a></span></dt>
<dd><p>Lorem Impsum.</p>
</dd>
</dl>
If I remove the caption, the figure opening HTML is rendered without id="id1", like this:
<figure class="align-center">
Is this a bug in sphinx?
Can I tell sphinx use the following id in figure to avoid collisions?

Clarification of Nokogiri::NodeSet XML Content based on 'puts node' and 'puts node.inspect'

I rarely use xpath() but when I do I keep tripping myself up on interpreting content of Nokogiri::Nodesets and believe I now know where I have always gone wrong.
Simply put when I do a 'puts NodeSet' I have always assumed that I could search the Nodeset based on the returned XML. But the first tag returned does not appear to actually part of the node XML.
'puts n1' returns XML that has a SPAN as the first element of the XML, but if I then do an search n1.xpath('SPAN') or n1.xpath('SPAN/DIV') no nodes are found. n1.xpath('DIV') returns the output I expect and proves no SPAN tag in the XML.
The only way I can logically explain this to myself is if assume that the first xml tag of a 'puts node' is the "Node Name" and not part of the node XML. This works for me going forward but am I missing something that is going to bite me elsewhere.
CODE:
docxml = Nokogiri::XML(<<EOT)
<DIV><SPAN><DIV id='1'><H1>-H1-</H1><h1>-h1-</h1></DIV>
<DIV id='2'><H2>-H2-</H2> <h2>-h2-</h2></DIV>
<DIV id='3'><H3>-H3-</H3><h3>-h3-</h3></DIV>
</SPAN></DIV>
EOT
n0 = docxml.xpath('DIV')
n1 = n0.xpath('SPAN')
n2 = n1.xpath('DIV')
n3 = n2.xpath('*')
n4 = n3.xpath('*')
puts "n1:xpath('SPAN'): \n#{n1.xpath('SPAN')}\n#{'^'*80} \nn1 XML:\n#{n1}\n#{'^'*80}\
\nn1:inspect \n#{n1.inspect}\n#{'^'*80}\n"
OUTPUT:
=begin
n1:xpath('SPAN'):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
n1 XML:
<SPAN>
<DIV id="1"> <H1>-H1-</H1> <h1>-h1-</h1> </DIV>
<DIV id="2"> <H2>-H2-</H2> <h2>-h2-</h2> </DIV>
<DIV id="3"> <H3>-H3-</H3> <h3>-h3-</h3> </DIV>
</SPAN>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
n1:inspect
[#<Nokogiri::XML::Element:0x1c10964 name="SPAN"
children=[
#<Nokogiri::XML::Element:0x1c10820 name="DIV" attributes=[#<Nokogiri::XML::Attr:0x18fff90 name="id" value="1">]
children=[#<Nokogiri::XML::Element:0x1c1064c name="H1" children=[#<Nokogiri::XML::Text:0x1c1ffe8 "-H1-">]>,
#<Nokogiri::XML::Element:0x1c10604 name="h1" children=[#<Nokogiri::XML::Text:0x1c1fdcc "-h1-">]>
]>,
#<Nokogiri::XML::Element:0x1c107d8 name="DIV" attributes=[#<Nokogiri::XML::Attr:0x1c1fc10 name="id" value="2">]
children=[#<Nokogiri::XML::Element:0x1c105bc name="H2" children=[#<Nokogiri::XML::Text:0x1c1f874 "-H2-">]>,
#<Nokogiri::XML::Text:0x1c1f778 " ">,
#<Nokogiri::XML::Element:0x1c10574 name="h2" children=[#<Nokogiri::XML::Text:0x1c1f5f8 "-h2-">]
>]>,
#<Nokogiri::XML::Element:0x1c10790 name="DIV" attributes=[#<Nokogiri::XML::Attr:0x1c1f43c name="id" value="3">]
children=[#<Nokogiri::XML::Element:0x1c1052c name="H3" children=[#<Nokogiri::XML::Text:0x1c1f0a0 "-H3-">]>,
#<Nokogiri::XML::Element:0x1c104e4 name="h3" children=[#<Nokogiri::XML::Text:0x1c1ee90 "-h3-">]
>]
>]
>]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
=end
Now that I have had some sleep this works for me.
'nodeset = xpath(tag1/tag2)' returns a 'nodeset' containing member node 'tag2'
'puts nodeset' displays the 'tag2' node member
'nodeset.xpath('*')' returns the content of 'tag2
'nodeset.xpath('tag2')' invalid as 'tag2' is not part of the content of 'tag2'

How to get Error message when using pattern in angular 2

I have tried this code but it is not working.
<div>
<span *ngIf="!usernameRef.errors?.required">Amount</span>
<span *ngIf="!usernameRef.errors?.required">Cover amount required.</span>
<span *ngIf="usernameRef.errors?.pattern">Cover amount invalid.</span>
<input type="number" name="Amount" class="form-control" data-field="validate" placeholder="50 000" [(ngModel)]="Amount"
required #usernameRef="ngModel" pattern="[0-9]*" />
</div>
Your regex is also valid from two reasons:
Your input type is a number. You can't type letters.
[0-9]* - the asterisk means - 0 or more occurrences.

Parse XML doc from url with ruby

I am not very familiar with XML and am learning ruby as I go. The problem I am having is that the xml file I am using is formatted different than all the examples out there. I am attempting to us Nokogiri as it seems to be a popular was of doing this.
My XML file is from a url and looks like this
<guides of="XML" rtn="5" tot="10" cv="1" a="XPU_NextStep" id="0" " w="" q="" g="Echo" gr="HomeRec" gt="doc" js_q="" token="0:1QeU|5iG|557|1Y7p|4rE|">
<r t="Orbelle Toddler Bed - Cappuccino" g="Echo" s="1" rk="1" pt="0" at="0" pr="0" ar="0">
<a n="onsale" v="Yes"/>
<a n="SKU" v="OTI041"/>
<display>
<thumb n="imageName" v="http://images/mgen/master:OTI041.jpg?is=400,400"/>
<labels>
<l n="salePrice" v="Sale Price: 69.98"/>
<l n="catName" v="Toddler Beds"/>
<l n="id" v="OTI041"/>
</labels>
</display>
</r>
<r t="The Orbelle Contemporary Solid Wood Toddler Bed - Cappuccino" g="XPU_NextStep" tm="bed, toddler, toddler bed, the orbelle contemporary solid wood toddler bed cappuccino, toddler beds" s="0.4688" rk="2" pt="873" at="0" pr="0" ar="0">
<a n="availableDomain" v="ToddlerBeds,KidsFurnitureMart"/>
<a n="deptName" v="Kids"/>
<a n="onsale" v="Yes"/>
<a n="SKU" v="OTI029"/>
<a n="nicheCategory" v="Kids Beds,Standard Toddler Beds"/>
<display>
<thumb n="imageName" v="http://images/mgen/master:OTI029.jpg?is=400,400"/>
<labels>
<l n="salePrice" v="Sale Price: 59.98"/>
<l n="catName" v="Toddler Beds"/>
</labels>
</display>
</r>
I am trying to grab the v="OTI041" from under each
Right now I am just able to open the file with-
doc = Nokogiri::XML(open("http://www.somesite.com"))
Use this XPath:
doc.xpath('//r/a[#n="SKU"]/#v').each {|x| puts x.value }
Also, note that you have a syntax error in the first line, at ... id="0" " ...

Locating element in same paragraph of another element in watir-webdriver

Given the following HTML code snippet; after finding the link by ID, how would you select the checkbox in the same paragraph?
For example if I wanted to select the checkbox associated with the link with ID="inst_17901-1746-1747".
The order of the paragraphs in the DIV is not consistent between sessions so I cannot select it by index or ID of the checkbox.
<div id="inst-results">
<p>
<input id="inst-results0-check" type="checkbox">
<a class="ws-rendered" id="inst_17901-1746-1747" title="!!QA Data 2/DOOR FURNITURE/316 Stainless - Altro Range"><img src="http://yr-qa-svr2/Agility/ACMSImages?type=objectType&objectTypeID=32"> <span>!!QA Data 2/DOOR FURNITURE/316 Stainless - Altro Range</span></a>
</p>
<p>
<input id="inst-results1-check" type="checkbox"><a class="ws-rendered" id="inst_17882-1746-1747" title="!!QA Data/DOOR FURNITURE/316 Stainless - Altro Range"><img src="http://yr-qa-svr2/Agility/ACMSImages?type=objectType&objectTypeID=32"> <span>!!QA Data/DOOR FURNITURE/316 Stainless - Altro Range</span></a>
</p>
</div>
I figured out this solution working off the text of the link, but Zeljko solution is much better.
$browser.div(:id,"inst-results").ps.each { |para|
if para.link.text == "!!QA Data/DOOR FURNITURE/316 Stainless - Altro Range" then
para.checkbox.set
break
end
}
If there is only one checkbox in the paragraph with the link:
browser.link(:id => "inst_17901-1746-1747").parent.checkbox.set
Works with watir-webdriver, not sure if it would work with other Watir gems.

Resources