Queries: Difference between revisions

From Wikisphere
Jump to navigation Jump to search
No edit summary
Tag: 2017 source edit
No edit summary
Tag: 2017 source edit
Line 93: Line 93:
|format=datatable  
|format=datatable  
}}
}}
{{#visualdataprint: {{FULLPAGENAME}} 
|?cover
|?title
|?authors/name
|?authors/email
|schema=Book
|template=Book
|template?authors=Book authors
|format=template
}}
 
This is a page with an infobox that demonstrates the use of VisualData ([https://gerrit.wikimedia.org/r/c/mediawiki/extensions/VisualData/+/968230 latest version]) used as a [https://en.wikipedia.org/wiki/Create,_read,_update_and_delete CRUD]
Click the button below to edit the article's metadata through a popup or the tab "Edit semantic" among the article's actions.
{{#visualdataform: Book
|title = edit infobox and page
|action = edit
|edit-page = {{FULLPAGENAME}}
|return-page =
|view = popup
|popup-size = medium
|css-class =
|pagename-formula =
|edit-freetext = true
|edit-categories = false
|edit-content-model = false
|default-categories =
|default-content-model = wikitext
|layout-align = top
|popup-help = true
|submit-button-text =
|layout = tabs
|submit-button-text =
|validate-button-text =
}}
The popup is rendered using the following code
<pre>
{{#visualdataform: Book
|title = edit infobox and page
|action = edit
|edit-page = {{FULLPAGENAME}}
|return-page =
|view = popup
|popup-size = medium
|css-class =
|pagename-formula =
|edit-freetext = true
|edit-categories = false
|edit-content-model = false
|default-categories =
|default-content-model = wikitext
|layout-align = top
|popup-help = true
|submit-button-text =
|layout = tabs
|submit-button-text =
|validate-button-text =
}}
</pre>
A Pageproperties' form can edit whatever page (through the parameter <code>edit-page</code>, and create new pages with user-defined title or using a pagename formula. It is [https://json-schema.org/ json/schema] compliant<ref>It does not yet support allOf, anyOf, oneOf, and $refs both in the editor and in the viewer</ref>  and can handle subitems, multiple fields and multiple sub items. It is deeply integrated with the Mediawiki's [https://doc.wikimedia.org/oojs-ui/master/demos/ OOUI library] and uses a lot or most of its features.
'''In the latest version can query properties and nested properties, as well as render them using templates and nested templates and does not rely on [https://www.semantic-mediawiki.org/wiki/Semantic_MediaWiki SemanticMediawiki]'''.
The infobox is rendered through the following code:
<pre>
{{#visualdataprint: {{FULLPAGENAME}}
|?cover
|?title
|?authors/name
|?authors/email
|schema=Book
|template=Book
|template?authors=Book authors
|format=template
}}
</pre>
This is a SemanticMediawiki-like parser function that can be used as a shorthand to invoke the more complex <code> {{#visualdataquery }} </code> parser function that can handle multi-page results and provides a basic query language. (more about this on the official page of the extension to be updated soon)
The results are rendered on the page using 2 templates, [[Template:Book]] and [[Template:Book authors]]. The second is used as a nested template rendered inside the parent template ([[Template:Book]]) entitled to render the properties with path <code>authors</code>. ''' Note that the parent template must include a reference to the name of the child template since both values and template's containers are passed as named parameters.'''
The form's schema(s) (a form can contain an arbitrary number of schemas, and a schema an arbitrary number of items and subitems) can be edited using this [[Special:ManageSchemas|Special page]] or [https://wikisphere.org/w/index.php?title=Test_visualdata_2.0&action=editsemantic this interface] (tab Edit semantic, edit icon on the right and then "Manage schemas")
The related [[VisualDataSchema:Book|schema]] created by the UI contains an hidden property "name" that is filled-in with the compounded value of the fields <code>first_name</code> and <code>last_name</code>.
Also, the cover file name contains a value-formula, that allows the file to be saved with the article-id as prefix (also for new articles) which is useful to easily upload on the wiki files with similar names.
Have fun with this extension !!





Revision as of 21:40, 28 January 2024

{{#visualdataquery:[[name::Afghanistan]] [[states/name::Badakhshan]]
|schema=Country 
|?states/cities/name
|?states/cities/latitude
|?states/cities/longitude
|format=datatable 
}} 
page titleNameLatitudeLongitude
Data:Countries/AfghanistanAshkāsham36.6833371.53333
Data:Countries/AfghanistanFayzabad37.1166470.58002
Data:Countries/AfghanistanJurm36.8647770.83421
Data:Countries/AfghanistanKhandūd36.9512772.318
Data:Countries/AfghanistanRāghistān37.6607970.67346
Data:Countries/AfghanistanWākhān37.057173.34928
{{#visualdataquery:[[name::Afghanistan]]   [[states/name::Badakhshan]] [[states/cities/name::A~]][[states/cities/latitude::36.68333000]] [[states/cities/restaurants/name::bbb]]      
|schema=Country   
|?states/cities/name
|?states/cities/latitude
|format=datatable 
}} 
page titleNameLatitude
Data:Countries/AfghanistanAshkāsham36.68333
{{#visualdataquery:[[name::Afghanistan]]   [[states/name::Badakhshan]] [[states/cities/name::A~]][[states/cities/restaurants/name::bbb]]      
|schema=Country   
|?states/cities/name
|?states/cities/latitude
|?states/cities/longitude
|format=json 
|hierarchical-conditions=true 
|pagetitle-name=article 
}} 
title"Data:Countries/Afghanistan"
pageid710
data
states
cities
name"Ashkāsham"
latitude36.68333
longitude71.53333
name"Fayzabad"
latitude37.11664
longitude70.58002
name"Jurm"
latitude36.86477
longitude70.83421
name"Khandūd"
latitude36.95127
longitude72.318
name"Rāghistān"
latitude37.66079
longitude70.67346
name"Wākhān"
latitude37.0571
longitude73.34928


{{#visualdataquery:[[name::Afghanistan]]
|schema=Country 
|?states/name
|?states/state_code
|format=table 
}}
page titleNameState code
Data:Countries/AfghanistanBadakhshanBDS
Data:Countries/AfghanistanBadghisBDG
Data:Countries/AfghanistanBaghlanBGL
Data:Countries/AfghanistanBalkhBAL
Data:Countries/AfghanistanBamyanBAM
Data:Countries/AfghanistanDaykundiDAY
Data:Countries/AfghanistanFarahFRA
Data:Countries/AfghanistanFaryabFYB
Data:Countries/AfghanistanGhazniGHA
Data:Countries/AfghanistanGhōrGHO
Data:Countries/AfghanistanHelmandHEL
Data:Countries/AfghanistanHeratHER
Data:Countries/AfghanistanJowzjanJOW
Data:Countries/AfghanistanKabulKAB
Data:Countries/AfghanistanKandaharKAN
Data:Countries/AfghanistanKapisaKAP
Data:Countries/AfghanistanKhostKHO
Data:Countries/AfghanistanKunarKNR
Data:Countries/AfghanistanKunduz ProvinceKDZ
Data:Countries/AfghanistanLaghmanLAG
Data:Countries/AfghanistanLogarLOG
Data:Countries/AfghanistanNangarharNAN
Data:Countries/AfghanistanNimruzNIM
Data:Countries/AfghanistanNuristanNUR
Data:Countries/AfghanistanPaktiaPIA
Data:Countries/AfghanistanPaktikaPKA
Data:Countries/AfghanistanPanjshirPAN
Data:Countries/AfghanistanParwanPAR
Data:Countries/AfghanistanSamanganSAM
Data:Countries/AfghanistanSar-e PolSAR
Data:Countries/AfghanistanTakharTAK
Data:Countries/AfghanistanUrozganURU
Data:Countries/AfghanistanZabulZAB
 
{{#visualdataquery:
[[name::Canada]][[states/name::Q~]]
|schema=Country
|?states/name 
|?states/cities/name 
|?states/cities/latitude 
|limit=50
|format=datatable 
}}
page titleNameNameLatitude
Data:Countries/CanadaQuebecAbitibi-Témiscamingue48.10018
Data:Countries/CanadaQuebecActon Vale45.65007
Data:Countries/CanadaQuebecAdstock46.05007
Data:Countries/CanadaQuebecAlbanel48.88324
Data:Countries/CanadaQuebecAlma48.55009
Data:Countries/CanadaQuebecAmos48.56688
Data:Countries/CanadaQuebecAmqui48.46382
Data:Countries/CanadaQuebecAnge-Gardien45.35008
Data:Countries/CanadaQuebecAsbestos45.76678
Data:Countries/CanadaQuebecBaie-Comeau49.21679
Data:Countries/CanadaQuebecBaie-D'Urfé45.41397
Data:Countries/CanadaQuebecBaie-Saint-Paul47.44109
Data:Countries/CanadaQuebecBarraute48.43349
Data:Countries/CanadaQuebecBas-Saint-Laurent48.0503
Data:Countries/CanadaQuebecBeaconsfield45.43341
Data:Countries/CanadaQuebecBeauceville46.21785
Data:Countries/CanadaQuebecBeauharnois45.31341
Data:Countries/CanadaQuebecBeaupré47.04428
Data:Countries/CanadaQuebecBécancour46.34106
Data:Countries/CanadaQuebecBedford45.11678
Data:Countries/CanadaQuebecBeloeil45.56839
Data:Countries/CanadaQuebecBerthierville46.08336
Data:Countries/CanadaQuebecBlainville45.66678
Data:Countries/CanadaQuebecBois-des-Filion45.66678
Data:Countries/CanadaQuebecBoisbriand45.61678
Data:Countries/CanadaQuebecBonaventure48.04573
Data:Countries/CanadaQuebecBoucherville45.59104
Data:Countries/CanadaQuebecBreakeyville46.68037
Data:Countries/CanadaQuebecBromont45.31678
Data:Countries/CanadaQuebecBrossard45.45008
Data:Countries/CanadaQuebecBrownsburg-Chatham45.68342
Data:Countries/CanadaQuebecBuckingham45.58563
Data:Countries/CanadaQuebecCabano47.68065
Data:Countries/CanadaQuebecCacouna47.91657
Data:Countries/CanadaQuebecCandiac45.38338
Data:Countries/CanadaQuebecCantley45.5668
Data:Countries/CanadaQuebecCap-Chat49.10009
Data:Countries/CanadaQuebecCap-Santé46.67159
Data:Countries/CanadaQuebecCapitale-Nationale47.376
Data:Countries/CanadaQuebecCarignan45.45008
Data:Countries/CanadaQuebecCarleton48.09838
Data:Countries/CanadaQuebecCarleton-sur-Mer48.10749
Data:Countries/CanadaQuebecCentre-du-Québec46.01985
Data:Countries/CanadaQuebecChambly45.45008
Data:Countries/CanadaQuebecChambord48.43339
Data:Countries/CanadaQuebecChandler48.34935
Data:Countries/CanadaQuebecChapais49.78344
Data:Countries/CanadaQuebecCharlemagne45.71678
Data:Countries/CanadaQuebecChâteau-Richer46.96031
Data:Countries/CanadaQuebecChâteauguay45.38338


See also


support & questions: support at topway.it

Download the latest version!