Difference between revisions of "Dynamic Page Generation"

From AIRWiki
Jump to: navigation, search
m
m (Examples of inline queries)
 
(41 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
Semantic queries can be used to automatically generate lists and tables of items satisfying some requirements.  
 
Semantic queries can be used to automatically generate lists and tables of items satisfying some requirements.  
  
For the complete documentation for inline queries see: http://semantic-mediawiki.org/wiki/Help:Inline_queries
+
For the complete documentation for inline queries see: http://semantic-mediawiki.org/wiki/Help:Inline_queries  
 
+
  
 
In this page you can find some examples of ad hoc queries that may be useful in this wiki.
 
In this page you can find some examples of ad hoc queries that may be useful in this wiki.
  
 +
= Examples of inline queries =
  
== All the Projects tutored by a given Tutor ==
+
=== Before you write anything: how to test your queries ===
 +
Remember that the very useful [[Special:Ask]] page lets you ''test your queries''! In this way, you can check them before inserting them into an actual AIRWiki page.
  
=== Results in an unordered list ===
+
=== All projects tutored by a given tutor ===
  
Specify all the conditions to be satisfied, followed by options separated by "|":
+
Specify all the conditions to be satisfied[http://semantic-mediawiki.org/wiki/Help:Selecting_pages], inside the #ask function:
  
  <nowiki>{{#ask: [[Category:Project]][[prjTutor::User:{{PAGENAME}}]]
+
  <nowiki>{{#ask: [[Category:Project]][[prjTutor::User:LeonardoDaVinci]] }}</nowiki>
| format = ul}}</nowiki>
+
  
This way the result will be displayed in "ul" format (a list).
+
The result of this query is: {{#ask: [[Category:Project]][[prjTutor::User:LeonardoDaVinci]] }}
  
You can see the result of the previous query [[User:RiccardoTasso#Tutored_projects|here]].  
+
==== Results in a list ====
 +
 
 +
Various parameters can be added in the command, each introduced by a "|". To display the results in a list, you can set the ''format'' option to "ul":
 +
 
 +
<nowiki>{{
 +
#ask: [[Category:Project]][[prjTutor::User:{{PAGENAME}}]]
 +
| format = ul
 +
}}</nowiki>
 +
 
 +
You can see the result of this query [[User:RiccardoTasso#Tutored_projects|here]].  
  
 
Note: <nowiki>{{PAGENAME}}</nowiki> is a variable which identifies the title of the current page.  
 
Note: <nowiki>{{PAGENAME}}</nowiki> is a variable which identifies the title of the current page.  
 
Putting this query inside a user's page, all projects tutored by that user will be shown as results.
 
Putting this query inside a user's page, all projects tutored by that user will be shown as results.
  
=== Results in an external link ===
+
==== Results in an external link ====
  
 
To display just a link to the results, you can add an option specifying a limit of 0, and a searchlabel for the name of the link:
 
To display just a link to the results, you can add an option specifying a limit of 0, and a searchlabel for the name of the link:
  
  <nowiki>{{#ask: [[Category:Project]][[prjTutor::User:RiccardoTasso]]
+
  <nowiki>{{#ask:  
 +
[[Category:Project]][[prjTutor::User:RiccardoTasso]]
 +
| limit=0
 +
| searchlabel=projects tutored by Riccardo Tasso
 +
}}</nowiki>
 +
 
 +
This way, a link to a dynamic page containing the results of the query will be created, like this:
 +
{{#ask:
 +
[[Category:Project]][[prjTutor::User:RiccardoTasso]]
 
| limit=0  
 
| limit=0  
| searchlabel=projects tutored by Riccardo Tasso}}</nowiki>
+
| searchlabel=projects tutored by Riccardo Tasso
 +
}}.
  
This way, a link to a dynamic page containing the results of the query will be created, with the name you choose in the "searchlabel" option: {{#ask: [[Category:Project]][[prjTutor::User:RiccardoTasso]]| limit=0 | searchlabel=projects tutored by Riccardo Tasso}}
+
The results are displayed in a table (the default format).
  
=== Showing more attributes ===
+
==== Showing more attributes ====
  
 
To show more details about the results, you can add the properties you want to be displayed.
 
To show more details about the results, you can add the properties you want to be displayed.
For example, to display the student, research topic, the student and the start and end dates of a projects:
+
For example, to display the students, research topic, and the start and end dates of a projects:
  
  <nowiki>{{#ask: [[Category:Project]][[prjTutor::User:RiccardoTasso]] | ?prjStudent = | ?HasResTopic = | ?PrjStarts = | PrjEnds = | limit = 0 | searchlabel = projects tutored by Riccardo Tasso}}</nowiki>
+
  <nowiki>{{#ask:  
 +
[[Category:Project]][[prjTutor::User:RiccardoTasso]]  
 +
| ? = Project
 +
| ?prjStudent = Students
 +
| ?PrjResTopic = Research Topic
 +
| ?PrjStart = Start
 +
| ?PrjEnd = End
 +
| limit = 0  
 +
| searchlabel = projects tutored by Riccardo Tasso
 +
}}</nowiki>
  
The query generates this link: {{#ask: [[Category:Project]][[prjTutor::User:RiccardoTasso]] | ?prjStudent = | ?HasResTopic = | ?PrjStarts = | PrjEnds = | limit = 0 | searchlabel = projects tutored by Riccardo Tasso}}
+
The query generates this link:  
 +
{{#ask:  
 +
[[Category:Project]][[prjTutor::User:RiccardoTasso]]  
 +
| ? = Project
 +
| ?prjStudent = Students
 +
| ?PrjResTopic = Research Topic
 +
| ?PrjStart = Start
 +
| ?PrjEnd = End
 +
| limit = 0  
 +
| searchlabel = projects tutored by Riccardo Tasso
 +
}}
  
== All master thesis proposals in a research area ==
+
=== All master thesis proposals in a research area ===
  
 
To generate the results in a list, showing the research topic of each proposal:
 
To generate the results in a list, showing the research topic of each proposal:
 +
 +
<nowiki>{{#ask:
 +
[[Category:ProjectProposal]]
 +
[[PrjLevel::Bs]]
 +
[[PrjType::Thesis]]
 +
[[PrjResArea::Robotics]]
 +
| ?PrjResTopic = topic:
 +
| format=list
 +
}}</nowiki>
 +
 +
Result:
 +
{{#ask:
 +
[[Category:ProjectProposal]]
 +
[[PrjLevel::Bs]]
 +
[[PrjType::Thesis]]
 +
[[PrjResArea::Robotics]]
 +
| ?PrjResTopic = topic:
 +
| format=list
 +
}}
 +
 +
 +
To generate a table in a dynamic page, showing the values of all the properties:
  
 
  <nowiki>{{#ask: [[Category:ProjectProposal]]  
 
  <nowiki>{{#ask: [[Category:ProjectProposal]]  
Line 50: Line 109:
 
[[PrjType::Thesis]]
 
[[PrjType::Thesis]]
 
[[PrjResArea::Social Software and Semantic Web]] |
 
[[PrjResArea::Social Software and Semantic Web]] |
?PrjResTopic |
+
? = Project Proposal
format=list
+
?PrjTitle = Title |
 +
?PrjDescription = Description |
 +
?PrjTutor = Tutors |
 +
?PrjStarts = Start |
 +
?PrjStudMin = StudMin |
 +
?PrjStudMax = StudMax |
 +
?PrjCFUMin = CFUMin |
 +
?PrjCFUMax = CFUMax |
 +
?PrjResArea = Research Area |
 +
?PrjResTopic = Research Topic |
 +
limit = 0 |
 +
searchlabel = result table
 
}}</nowiki>
 
}}</nowiki>
  
 +
See the
 +
{{#ask: [[Category:ProjectProposal]]
 +
[[PrjLevel::Bs]]
 +
[[PrjType::Thesis]]
 +
[[PrjResArea::Social Software and Semantic Web]] |
 +
?PrjTitle = Title |
 +
?PrjDescription = Description |
 +
?PrjTutor = Tutors |
 +
?PrjStarts = Start |
 +
?PrjStudMin = StudMin |
 +
?PrjStudMax = StudMax |
 +
?PrjCFUMin = CFUMin |
 +
?PrjCFUMax = CFUMax |
 +
?PrjResArea = Research Area |
 +
?PrjResTopic = Research Topic |
 +
limit = 0 |
 +
searchlabel = result table
 +
}}
 +
 +
==== Visualizing results in a template ====
  
An apposite template has been created for the visualization of project proposals
+
An [[Template:ProjectProposalViz|apposite template]] has been created for the visualization of project proposals.
To show the results in the template [[Template:ProjectProposalViz|ProjectProposalViz]]:
+
To show the results inside the template:  
  
 
  <nowiki>{{#ask: [[Category:ProjectProposal]]  
 
  <nowiki>{{#ask: [[Category:ProjectProposal]]  
Line 62: Line 152:
 
[[PrjType::Thesis]]
 
[[PrjType::Thesis]]
 
[[PrjResArea::Social Software and Semantic Web]] |
 
[[PrjResArea::Social Software and Semantic Web]] |
?PrjTitle |
+
?PrjTitle = |
?PrjImage |
+
?PrjImage = |
?PrjDescription |
+
?PrjDescription = |
?PrjTutor |
+
?PrjTutor = |
?PrjStarts |
+
?PrjStarts = |
?PrjStudMin |
+
?PrjStudMin = |
?PrjStudMax |
+
?PrjStudMax = |
?PrjCFUMin |
+
?PrjCFUMin = |
?PrjCFUMax |
+
?PrjCFUMax = |
?PrjResArea |
+
?PrjResArea = |
?PrjResTopic |
+
?PrjResTopic = |
 
format = template |
 
format = template |
 
template = Template:ProjectProposalViz
 
template = Template:ProjectProposalViz
Line 79: Line 169:
 
You can see the result of this query [[Master_Level_Theses#Social_Software_and_Semantic_Web|here]].
 
You can see the result of this query [[Master_Level_Theses#Social_Software_and_Semantic_Web|here]].
  
 +
=== All finished projects on a research topic, ordered by descending end date ===
  
== All finished projects in a research topic, ordered by end date ==
+
  <nowiki>{{#ask:  
 
+
[[Category:Project]][[prjResTopic::Folksonomies]][[prjStatus::Closed]]
  <nowiki>{{#ask: [[Category:Project]][[prjResTopic::Folksonomies]][[prjStatus::Closed]]|?prjTitle = |sort=prjEnd|order=desc|format=ul}}</nowiki>
+
| ?PrjTitle =  
 +
| sort=prjEnd
 +
| order=desc
 +
| format=ul
 +
}}</nowiki>
  
 
See the result [[Finished_Projects#Semantic_Tagging|here]].
 
See the result [[Finished_Projects#Semantic_Tagging|here]].
 +
 +
=== All theses tutored by a PhD advised by a given professor ===
 +
 +
<nowiki>{{#ask:
 +
[[Category:Project]]
 +
[[PrjType::Thesis]]
 +
[[PrjTutor::<q> [[Category:PhD]][[HasAdvisor::User:AndreaBonarini]]</q>]]
 +
| ? = Project
 +
| ?PrjTutor = tutors
 +
| ?PrjType = type
 +
| ?PrjLevel = level
 +
| limit = 0
 +
| searchlabel = result
 +
}}</nowiki>
 +
 +
See the
 +
{{#ask:
 +
[[Category:Project]]
 +
[[PrjType::Thesis]]
 +
[[PrjTutor::<q> [[Category:PhD]][[HasAdvisor::User:AndreaBonarini]]</q>]]
 +
| ? = Project
 +
| ?PrjTutor = tutors
 +
| ?PrjType = type
 +
| ?PrjLevel = level
 +
| limit = 0
 +
| searchlabel = result
 +
}}
 +
 +
Note: a query enclosed in <q> and </q> is used as a property condition for the external query. Arbitrary levels of nesting are allowed.
 +
 +
=== All project proposals on a given topic or on a sub topic of a given area ===
 +
 +
All projects on the topic [[Semantic Tagging]] or on a sub topic of the area [[BioSignal Analysis]]:
 +
 +
<nowiki>{{#ask:
 +
[[Category:Project]][[PrjResTopic::<q>[[Semantic Tagging]] OR [[BelongsToArea::BioSignal Analysis]]</q>]]
 +
| ? = Project
 +
| ?PrjResTopic = research topic
 +
| ?PrjResArea = research area
 +
| sort = prjResArea
 +
| limit = 0
 +
| searchlabel = result
 +
}}</nowiki>
 +
 +
See the
 +
{{#ask:
 +
[[Category:Project]][[PrjResTopic::<q>[[Semantic Tagging]] OR [[BelongsToArea::BioSignal Analysis]]</q>]]
 +
| ? = Project
 +
| ?PrjResTopic = research topic
 +
| ?PrjResArea = research area
 +
| sort = prjResArea
 +
| limit = 0
 +
| searchlabel = result
 +
}}.
 +
 +
Note: a query enclosed in <q> and </q> is used as a property condition for the external query. Arbitrary levels of nesting are allowed.
 +
 +
== Projects involving students advised by someone advised by someone who works in the area of Robotics :) ==
 +
 +
<nowiki>[[PrjStudent.HasAdvisor.HasAdvisor.HasResArea::Robotics]]</nowiki>
 +
 +
See the
 +
{{#ask:
 +
[[PrjStudent.HasAdvisor.HasAdvisor.HasResArea::Robotics]]
 +
| ? = Project
 +
| limit = 0
 +
| searchlabel = result
 +
}}.
 +
 +
Note: this query uses an alternative syntax for chains of properties.
 +
 +
= Ask Page =
 +
 +
In the page [[Special:Ask]] you can try any query, specifying conditions and printout options.
 +
 +
= Useful Documentation =
 +
 +
* [http://semantic-mediawiki.org/wiki/Help:Inline_queries Documentation for Inline queries]
 +
* [http://semantic-mediawiki.org/wiki/Help:Selecting_pages Documentation for selecting pages]
 +
* [http://semantic-mediawiki.org/wiki/Help:Displaying_information Documentation for displaying information]

Latest revision as of 09:57, 15 February 2010

Semantic queries can be used to automatically generate lists and tables of items satisfying some requirements.

For the complete documentation for inline queries see: http://semantic-mediawiki.org/wiki/Help:Inline_queries

In this page you can find some examples of ad hoc queries that may be useful in this wiki.

Examples of inline queries

Before you write anything: how to test your queries

Remember that the very useful Special:Ask page lets you test your queries! In this way, you can check them before inserting them into an actual AIRWiki page.

All projects tutored by a given tutor

Specify all the conditions to be satisfied[1], inside the #ask function:

{{#ask: [[Category:Project]][[prjTutor::User:LeonardoDaVinci]] }}

The result of this query is: Flying machine

Results in a list

Various parameters can be added in the command, each introduced by a "|". To display the results in a list, you can set the format option to "ul":

{{
 #ask: [[Category:Project]][[prjTutor::User:{{PAGENAME}}]]
 | format = ul
 }}

You can see the result of this query here.

Note: {{PAGENAME}} is a variable which identifies the title of the current page. Putting this query inside a user's page, all projects tutored by that user will be shown as results.

Results in an external link

To display just a link to the results, you can add an option specifying a limit of 0, and a searchlabel for the name of the link:

{{#ask: 
 [[Category:Project]][[prjTutor::User:RiccardoTasso]]
 | limit=0 
 | searchlabel=projects tutored by Riccardo Tasso
}}

This way, a link to a dynamic page containing the results of the query will be created, like this: projects tutored by Riccardo Tasso.

The results are displayed in a table (the default format).

Showing more attributes

To show more details about the results, you can add the properties you want to be displayed. For example, to display the students, research topic, and the start and end dates of a projects:

{{#ask: 
 [[Category:Project]][[prjTutor::User:RiccardoTasso]] 
 | ? = Project
 | ?prjStudent = Students 
 | ?PrjResTopic = Research Topic 
 | ?PrjStart = Start 
 | ?PrjEnd  = End 
 | limit = 0 
 | searchlabel = projects tutored by Riccardo Tasso
 }}

The query generates this link: projects tutored by Riccardo Tasso

All master thesis proposals in a research area

To generate the results in a list, showing the research topic of each proposal:

{{#ask: 
[[Category:ProjectProposal]] 
[[PrjLevel::Bs]]
[[PrjType::Thesis]]
[[PrjResArea::Robotics]] 
| ?PrjResTopic = topic: 
| format=list
}}

Result: Barking Robots (topic: Robot development), BringMeHome (topic: E-2? - A robot for exhibitions), Designing Living Objects (topic: Living Objects), R2P IMU firmware development (topic: Robot development), Robot Games (topic: Robogames), Scan Matching Odometry and Multisensor SLAM (topic: None), Soccer Robots (topic: Robot development), Unmanned Aerial Vehicles Visual Navigation (topic: None)


To generate a table in a dynamic page, showing the values of all the properties:

{{#ask: [[Category:ProjectProposal]] 
[[PrjLevel::Bs]]
[[PrjType::Thesis]]
[[PrjResArea::Social Software and Semantic Web]] |
? = Project Proposal
?PrjTitle = Title |
?PrjDescription = Description |
?PrjTutor = Tutors |
?PrjStarts = Start |
?PrjStudMin = StudMin |
?PrjStudMax = StudMax |
?PrjCFUMin = CFUMin |
?PrjCFUMax = CFUMax |
?PrjResArea = Research Area |
?PrjResTopic = Research Topic |
limit = 0 |
searchlabel = result table
}}

See the result table

Visualizing results in a template

An apposite template has been created for the visualization of project proposals. To show the results inside the template:

{{#ask: [[Category:ProjectProposal]] 
[[PrjLevel::Bs]]
[[PrjType::Thesis]]
[[PrjResArea::Social Software and Semantic Web]] |
?PrjTitle = |
?PrjImage = |
?PrjDescription = |
?PrjTutor = |
?PrjStarts = |
?PrjStudMin = |
?PrjStudMax = |
?PrjCFUMin = |
?PrjCFUMax = |
?PrjResArea = |
?PrjResTopic = |
format = template |
template = Template:ProjectProposalViz
}}

You can see the result of this query here.

All finished projects on a research topic, ordered by descending end date

{{#ask: 
 [[Category:Project]][[prjResTopic::Folksonomies]][[prjStatus::Closed]]
 | ?PrjTitle = 
 | sort=prjEnd
 | order=desc
 | format=ul
 }}

See the result here.

All theses tutored by a PhD advised by a given professor

{{#ask:
 [[Category:Project]]
 [[PrjType::Thesis]]
 [[PrjTutor::<q> [[Category:PhD]][[HasAdvisor::User:AndreaBonarini]]</q>]]
 | ? = Project
 | ?PrjTutor = tutors
 | ?PrjType = type
 | ?PrjLevel = level
 | limit = 0 
 | searchlabel = result
 }}

See the result

Note: a query enclosed in and is used as a property condition for the external query. Arbitrary levels of nesting are allowed.

All project proposals on a given topic or on a sub topic of a given area

All projects on the topic Semantic Tagging or on a sub topic of the area BioSignal Analysis:

{{#ask:
 [[Category:Project]][[PrjResTopic::<q>[[Semantic Tagging]] OR [[BelongsToArea::BioSignal Analysis]]</q>]]
 | ? = Project
 | ?PrjResTopic = research topic
 | ?PrjResArea = research area
 | sort = prjResArea
 | limit = 0 
 | searchlabel = result
 }}

See the result.

Note: a query enclosed in and is used as a property condition for the external query. Arbitrary levels of nesting are allowed.

Projects involving students advised by someone advised by someone who works in the area of Robotics :)

[[PrjStudent.HasAdvisor.HasAdvisor.HasResArea::Robotics]]

See the result.

Note: this query uses an alternative syntax for chains of properties.

Ask Page

In the page Special:Ask you can try any query, specifying conditions and printout options.

Useful Documentation