Tiddlywiki 5: filter tiddlers by concatenation of few fields - tiddlywiki

Trying to adopt this awesome engine as personal task tracker. Having few main types of tiddlers: day, week, sprint, event and task.
All of them have few user fields:
day_since,
month_since,
year_since,
day_due,
month_due,
year_due.
For example,
the task will have fields:
day_due="23"
month_due="02"
year_due="2022"
the week will have fields:
day_since="21"
month_since="02"
year_since="2022"
day_due="27"
month_due="02"
year_due="2022"
I do not use date type for purpose - i use xx instead of numbers for some events - like birthdays and holidays to be repeated every year, so i put xx instead of year number etc.
I want to filter tasks to show all tasks, fitting into week duration - i have day, month and year both for start and end of the week andd need to build and expression how to shoow all fitting task on the week card.
Got stuck with searching the solution. I use tiddlywiki 5.2.1. Would appreciate any advices.

i've got the solution kindly provided be talk.tiddlywiki.org members:
here is working code from template:
<$list filter="[is[current]tag[week]]" >
<$let
week_start={{{ [{!!since_year}] [{!!since_month}] [{!!since_day}]+[join[]] }}}
week_end={{{ [{!!due_year}] [{!!due_month}] [{!!due_day}]+[join[]] }}}
>
<h2>days:</h2>
<$list filter="[tag[day]]">
<h3> {{{ [{!!due_year}] [{!!due_month}] [{!!due_day}]+[join[]] +[compare:number:gteq<week_start>compare:number:lteq<week_end>then<currentTiddler>] }}} </h3>
</$list>
<h2>corresponding sprint:</h2>
<$list filter="[tag[sprint]]">
<$let
sprint_start={{{ [<currentTiddler>get[since_year]] [<currentTiddler>get[since_month]] [<currentTiddler>get[since_day]] +[join[]] }}}
sprint_end={{{ [<currentTiddler>get[due_year]] [<currentTiddler>get[due_month]] [<currentTiddler>get[due_day]] +[join[]] }}}
>
<h3> {{{ [<week_end>compare:number:gteq<sprint_start>compare:number:lteq<sprint_end>then<currentTiddler>] }}} </h3>
</$let>
</$list>
</div>
</$let>
</$list>
the concat i needed could be implemented by [join[]]

Related

*ngIf directive in Angular does not refresh the template when the condition is not met

I have an angular mat-table where I show a calendar with data and I want to show all the days of the month or only one of the 2 fortnights, so I have one variables to set the type of vision of my calendar (vistaCalendario) and another one to set the fortnight (quincenaurl).
The type of vision is selected from these icons
But this condition is no respected
the column M1 should only be shown when vista Calendario is "mes" or "quincena" but quincena en la Url is 1 and here that condition is not met and even so it is shown
Any idea, please?
Thanks
Its better to use switchabe div
<div *ngIf="vistaCalendario == 'mes'; else elseTemplate" >
--Your code----
</div>
<div #elseTemplate *ngIf="vistaCalendario == 'quincena' && quincenaurl == 1" >
----Your code----
</div>

Please help to extract date using xpath

<div class='postbodytop">
<a class="xxxxxxxxxxxxxxxx" href="xxxxxxxxxxxxxx">tonyd</a>
"posted this 4 minutes ago "
<span class="hidden-xs"> </span>
</div>
Hello, I want to extract the "posted this 4 minutes ago" or just "4 minutes" using xpath. Can anybody help me? Thank you
The div whose class equals postbodytop contains three child nodes: a span, a text node, and another span. Your path should start at the div and then select the child text node, for which the appropriate test is text().
div/text()
Of course this is just a fragment of a bigger page, and your XPath may need to have something at the start e.g. /html/body/ etc. and if there are other div elements at the same level as the <div class=postbodytop>, then you should be more specific about the div, e.g. div[#class="postbodytop"] instead of just div in that XPath expression.

XPath "and" Confusion

I recently started a new job that uses cucumber/Gherkin along with selenium. I was trying to create a XPath for a specific element. The xml looks slightly like this...
<p>
<div class="slds-text-title_bold slds-m-bottom_x-small ncc-input-label">
Amp
</div>
<div class="slds-text-title_bold slds-m-bottom_x-small ncc-input-label required-field-label">
Voltage
</div>
</p>
I am looking to only get the div with the required field label in the class and text of "Voltage" So far this kinda works...
//div[contains(text(), "Voltage")] | //*[contains(class, "required-field-label")]
however I'm getting way too many false positives. Any time I change the pipe into "and" I get nothing. What am I doing wrong?
HCSloan
Try the following expression on your actual code, and see if it works:
//div[contains(#class, "required-field-label")][contains(text(), "Voltage")]
You can match the element using "and" like this:
//div[contains(#class, 'required-field-label') and contains(text(), 'Voltage')]

Need a little push to build an Xpath expression

The xpath I have defined below is working properly if tested individually. However, when I call
it from storage object and make that structure look like as underneath, trouble comes up and generates
disorganized results. Ignore my linguistic mistakes, if any.
Storage=xpath('//div[#class="info"]')
for item in Storage:
Name=item.xpath('//span[#itemprop="name"]/text()')
Address=item.xpath('//span[#itemprop="streetAddress" and #class="street-address"]/text()')
Phone=item.xpath('//div[#itemprop="telephone" and #class="phones phone primary"]/text()')
My question is: How to build an xpath expression If it is taken from "storage" and built "Name", "Address", and "Phone"
as I tried to do above. Thanks.
Here is the html element for that expression, if needed.
<div class="info"><h2 class="n">36. <span itemprop="name">The Coffee Table Eagle Rock</span></h2><div data-tripadvisor="{"rating":"4.0","count":"11"}" data-israteable="true" class="info-section info-primary"><div class="result-rating three half "><span class="count">(5)</span></div><div class="ta-rating extra-rating ta-4-0"></div><span class="ta-count">(11)</span><p itemscope="" itemtype="http://schema.org/PostalAddress" itemprop="address" class="adr"><span itemprop="streetAddress" class="street-address">1958 Colorado Blvd</span><span itemprop="addressLocality" class="locality">Los Angeles, </span><span itemprop="addressRegion">CA</span> <span itemprop="postalCode">90041</span></p><div itemprop="telephone" class="phones phone primary">(323) 255-2200</div></div><div class="info-section info-secondary"><div class="categories">Coffee & Espresso RestaurantsBars</div><div class="links">WebsiteMenu</div><a data-analytics="{"adclick":true,"events":"event7,event6","category":"8004238","impression_id":"fbd98612-6b8a-43c2-b31e-fd579de20126","listing_id":"11287432","item_id":-1,"listing_type":"free","ypid":"11287432","content_provider":"MDM","srid":"L-webyp-1c6db222-cc63-48d8-90d1-2d5dc8754cca-11287432","item_type":"PUP","lhc":"8004238","ldir":"LA","rate":3.5,"hasTripAdvisor":true,"mip_claimed_staus":"mip_unclaimed","mip_ypid":"11287432","click_id":523,"listing_features":"orderonline"}" href="https://yellowpages.pingup.com/Bkm3xG?ypid=11287432&uvid=t3pfPllxtLYkH2dlkSbiCC1marvZprsz1YhqhycO80NYrDv0OMX3uTJ3ryFG464RywmpWCrB&source=web-prod" rel="nofollow" target="_blank" class="action order-online" data-impressed="1">Order Online</a></div><div class="preferred-listing-features"></div><div class="snippet"><figure class="avatar-1 color-1"></figure><p class="body with-avatar">I went here recently with my 2 year old for breakfast. I got the Silverlake omelet and the breakfast sandwich for my son. The food was great (especi…</p></div></div>
If you want to get child/descendant elements of already defined item, you need to use .// to point on current ("item") element, but not // that points on root element. Try below:
Storage=xpath('//div[#class="info"]')
for item in Storage:
Name=item.xpath('.//span[#itemprop="name"]/text()')
Address=item.xpath('.//span[#itemprop="streetAddress" and #class="street-address"]/text()')
Phone=item.xpath('.//div[#itemprop="telephone" and #class="phones phone primary"]/text()')

XPath for Google Results: <em> and description without date

I have 3 questions:
1) How can I XPath the text in the Google Results, the bold marked. If there's no , there should be nothing shown.
2) =XPathOnUrl("https://www.google.de/search?q=KEYWORD&num=10");"//span[#class='st']") This gives me the Google Description, but how can i get the description without the <span class="f"> date?
3) I get the description with � as an "ä, ö, ü". How can these letters be displayed?
HTML DOM CODE:-
<span class="st">
<span class="f">18.11.2009 - </span>
This Thursday 19th November
<em>Moonshine</em>
turns 4 years old. I'm proud to say that's 4 years of Malaysian acts pretty much every month. We've ...
</span>
The code I used for this issue
driver.get("https://www.google.de/?gws_rd=ssl#q=moonshine+site:blogspot.com&nu%E2%80%8C%E2%80%8Bm=10");
List<WebElement> ele = driver.findElements(By.xpath("//span[#class='f']/following-sibling::text()"));
ele.toString();
for(int i=0;i<ele.size();i++)
{
System.out.println(ele.get(i).getText());
}
This code throws an InvalidSelectorException
The result of the xpath expression "//span[#class='f']/following-sibling::text()" is: [object Text]. It should be an element.
In future you try this following xpath to capture only the text i.e. description
//span[#class='f']/following-sibling::text()
Actually you can't capture that text because this is selenium Open Issue
[selenium-developer-activity] Issue 5459 in selenium: InvalidSelectorError: The result of the xpath expression is: [object Text]
you can find it in below link (issue details)
http://grokbase.com/t/gg/selenium-developer-activity/13475y4cgj/issue-5459-in-selenium-invalidselectorerror-the-result-of-the-xpath-expression-is-object-text
Use below Xpath for same. It will return all the dates present on the page:-
//span[#class='f']/text()
if you just want text the use below xpath
//span[#class='st' and not(#class='f')]/text()
Hope it will help you :)

Resources