Rename hyperlinks in query result in Semantic MediaWiki - mediawiki

Here is my query
{{#ask: [[Category:Pages]]
|mainlabel = Link
|? volume = Volume
|? page = Volume page
|? title = Title
|limit = 3
}}
The result table is like (screenshot)
Link Volume Volume page Title
HPB-SB-1-1 1 1 Article A
HPB-SB-1-10 1 10 Article B
HPB-SB-1-100 1 100 Article C
Where each cell in Link column is actually a hyperlink leading to the corresponding page. What I need to do is somehow rename the cells in Link column to still be hyperlinks but have name of ones from Title column. So the result table become:
Link Volume Volume page
Article A 1 1
Article B 1 10
Article C 1 100
Does anyone knows how can this be achieved with Semantic Mediawiki? Thanks in advance!

You want to use template format:
{|
! Link !! Volume !! Volume page
{{#ask: [[Category:Pages]]
|mainlabel = Link
|? volume = Volume
|? page = Volume page
|? title = Title
|limit = 3
|format = template
|template = table_row
}}
|}
where Template:table_row is:
{{!}}-
{{!}} [{{{1}}}} {{{4}}}] {{!}}{{!}} {{{2}}} {{!}}{{!}} {{{3}}}

Related

How to get readable text from html block

region = input("Insert region of search ").lower()
#Get region of the world for language
first_name , last_name = input("").split()
#Get first and last name of person of interest or object
res = requests.get("https://"+ region + ".wikipedia.org/wiki/" + first_name + "_" + last_name)
#get Wiki page of person/object
soup = BeautifulSoup(res.text, "html.parser")
#Parse in html
infobox = (soup.select("img")[:4])
#Get the first 4 images
content = (soup.select("p")[0])
#Get the first block of text
for info in range(len(infobox)):
link = infobox[info].get("src")
if first_name in link:
urllib.request.urlretrieve("http:" + link, "sample.png")
img = Image.open("sample.png")
img.show()
break
#Loop through images until it finds the one about the person/object
So I made this small program, that basically brings back the picture of what you search for - I'm sure it can be improved, if you have any feedback/tips - but I also want to get the first block of text from the wiki article - I am able to get the block of html text, but I do I remove the <p> and <b> ?
Found it, you just have to put ".text" in the content

How can I add a menu for each content type in hugo

I have the following directory structure for my hugo site:
content/
- posts/
- some_post.md
- talks
- some_talk.md
about.md
I would like the main menu for this site to include entries for posts and talks. Currently I am able to add a menu item for about, by adding menus = main to the front matter, however, I would like the posts and talks links to redirect to indexes of their content, rather than be static pages that I maintain directly. Is this possible?
It turns out that this is possible using the menu configuration in config.toml. The weight attribute is used for ordering the menus:
[menu]
[[menu.main]]
identifier = "home"
name = "home"
url = "/"
weight = 10
[[menu.main]]
identifier = "blog"
name = "blog"
url = "/post/"
weight = 20
[[menu.main]]
identifier = "talks"
name = "talks"
url = "/talks/"
weight = 30
[[menu.main]]
identifier = "about me"
name = "about me"
url = "/about/"
weight = 40

angular 5: template binding within table row

How do you bind a template containing tds within a tr?
I have a table that I want column sections to be dynamically added/removed/rearranged.
My tds are grouped into categories, the user can pick categories, and then the sections of the table should be pieced together with if/then logic using the category ids.
I'm having trouble binding my category templates into tr. I've tried:
setting the component selector to "app-componentName" and inputting the component using <app-componentName></app-componentName>
setting the component selector to "[app-componentName]" and inputting the component using <template app-componentName></template>
but neither works correctly. Using the first option, all of the data from my category is put into one td. Using the second option, none of my categories show up at all.
Here's the gist...
table-row.component.ts
...
var selectedCategories = [
{
id: 2,
name: "billing address"
},
{
id: 1,
name: "name"
}
];
...
table-row.component.html
<ng-container *ngFor="let category of selectedCategories">
<app-name-cells [person]="person" *ngIf="category.id === 1">
<app-billing-address-cells [person]="person" *ngIf="category.id === 2">
</ng-container>
name-cells.component.html
<td>{{user.firstName}}</td>
<td>{{user.middleName}}</td>
<td>{{user.lastName}}</td>
billing-address-cells.component.html
<td>{{user.billingAddress.line1}}</td>
<td>{{user.billingAddress.line2}}</td>
<td>{{user.billingAddress.city}}</td>
<td>{{user.billingAddress.state}}</td>
<td>{{user.billingAddress.zip}}</td>
Result
//full address in first cell, full name in second cell
|| 123 Main St New York NY 12345 | John A Doe ||
Expected Result
// each part of each component in it's own cell
|| 123 Main St | New York | NY | 12345 | John | A | Doe ||
Edit - Added StackBlitz:
See code example: StackBlitz

Jekyll, how to display images in a folder by date?

I am creating a website gallery. There is such a structure:
my site
artworks
caty1
caty2
It is necessary to display the photos in page of a given category (caty2 or caty1) by creation date.
Actually, how to realize using Jekyll and Liqiud?
Or is there a more appropriate structure for this?
with liquid you can filter/sort an array but any of its elements attribute that you want.
in your case you need to create datafile (in yml, csv or json) representing a collection of photos, and each photo should have a date attribute (along with a name, src, ...).
then in the layout that generate a caty page you'll have some thing like:
{% assign sorted-photos = site.data.photos | sort: 'date' %}
<ul> <!-- list of sorted photos -->
{% for photo in photos %}
<li> <img src={{photo.src}} alt={{photo.name}}></li>
{% endfor %}
</ul>
the photos collection would be a photos.yml file located in _data directory with a structure similar to:
- src = assets/img/p1.jpg
date = 10-01-2017
name = cute cat
category = cats # if you need to filter by category ?
- src = assets/img/p2.jpg
date = 12-01-2017
name = grumpy cat-2
category = cats
- src = assets/img/p3.jpg
date = 10-11-2016
name = cool dog
category = dogs

list() contains one element but it has matrix of string inside, how do I convert this element into matrix?

After converting JSON data into a list using jsonlite, i end up with one of the list looking like following
In this case, 10th element contain a list of 9 columns (always fixed) and 2 rows (varies everytime).
mat <- lset$data$comments$data[10]
mat
[[1]]
id can_remove created_time from.id
1 10152663742099258_10152663749369258 TRUE 2014-07-01T11:10:29+0000 10203711779968366
2 10152663742099258_10152663842204258 TRUE 2014-07-01T12:15:57+0000 706804257
3 10152663742099258_10152663929639258 TRUE 2014-07-01T13:25:28+0000 10152738599744416
4 10152663742099258_10152663976344258 TRUE 2014-07-01T13:59:33+0000 706804257
from.name like_count
1 Aileen Yeow 1
2 Tejas Damania 0
3 Sandeep Kulkarni 1
4 Tejas Damania 0
message
1 Lame statement
2 Don't forget, people like you only because they don't know you! <ed><U+00A0><U+00BD><ed><U+00B8><U+00A1>
3 ...for a second I thought it's Accenture Singapore office with some new theme similar to its brand!
4 This is shanghai and nothing to do with firm I work for <ed><U+00A0><U+00BD><ed><U+00B8><U+008E>
user_likes
1 FALSE
2 FALSE
3 TRUE
4 FALSE
Whole mat shows us as a list of [1]
As you can see, it contains list (within a list?). When i print mat then it shows a structure as seen above.
typeof(mat)
[1] "list"
substring(mat,1,100)
[1] "list(id = c(\"10152663742099258_10152663749369258\", \"10152663742099258_10152663842204258\", \"101526637"
I cant access specific elements (say message) from this. Nor I am able to convert this into a matrix of strings so I can access the elements in structured way.
I changed the fromJSON call parameter to by setting simplifyVector = FALSE (which is default set to true)
lset <- fromJSON(jsonobj, simplifyVector = F, flatten=TRUE, unicode = TRUE)
this changes the way mat is formed, code maintain nesting all the way down to each leaf element. I can keep going deeper using $ and find the string value only at leaf element!
lset$data[[x]]$comments$data[[y]]$from$name
That works for now! thanks for all the help