注意:

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Difference between revisions of "Semantic MediaWiki Events"

From Funtoo
Jump to navigation Jump to search
Tag: visualeditor
 
(4 intermediate revisions by the same user not shown)
Line 4: Line 4:


== Creating Semantic Properties ==
== Creating Semantic Properties ==
The EventCalendar implementation suggests the creation of the following properties and types in Semantic MediaWiki. These property names can be changed, however -- if you use different property names, just remember to substitute your property names in your Event template as well as your calendar queries. Here are the "standard" property names and types:
The EventCalendar implementation suggests the creation of the following properties and types in Semantic MediaWiki. These property names can be changed -- however, if you use different property names, just remember to substitute your property names in your Event template as well as your calendar queries. Here are the "standard" property names and types:
* '''Has event''' (text -- the name of the event)
* '''Has event''' (text -- the name of the event)
* '''Has event start '''(date)
* '''Has event start '''(date)
Line 13: Line 13:
* '''Has event icon''' (page)
* '''Has event icon''' (page)
* '''Has event color '''(text)
* '''Has event color '''(text)
__NOCACHE__
 
'''Important Note:''' If your calendar is not displaying properly, make sure that these (or similar) properties have been created, and that they have the proper types.


== Semantic Template ==
== Semantic Template ==
Line 64: Line 65:
   |description=Good times
   |description=Good times
  }}</nowiki>
  }}</nowiki>
== Scratch Space ==
{{Event
{{Event
|event=Massa ac metus porttitor neque
|event=Massa ac metus porttitor neque

Latest revision as of 02:33, May 24, 2014

Semantic MediaWiki, in combination with the Semantic Result Formats extension, can be used to store and display calendar events on a MediaWiki wiki. Internally, events should be stored as subobjects. In the simplest sense, think of subobjects as invisible wiki pages that hold their own semantic properties. They have a parent wiki page, but the properties are stored in the subobject itself, not the page.

The most optimal way to implement events is via a template, such as the Event Template. You define this template on a page, and it expands and defines a subobject that contains semantic properties that define an event. Then, to display events, you can use the EventCalendar result format for displaying results of a query. This will present query results in a jQuery-based calendar widget.

Creating Semantic Properties

The EventCalendar implementation suggests the creation of the following properties and types in Semantic MediaWiki. These property names can be changed -- however, if you use different property names, just remember to substitute your property names in your Event template as well as your calendar queries. Here are the "standard" property names and types:

  • Has event (text -- the name of the event)
  • Has event start (date)
  • Has event end (date)
  • Has event description (text)
  • Has event location (text)
  • Has event type (text)
  • Has event icon (page)
  • Has event color (text)

Important Note: If your calendar is not displaying properly, make sure that these (or similar) properties have been created, and that they have the proper types.

Semantic Template

An Event template is used to store an event as a subobject on the current page. A simple Event template would contain the following wikitext:

{{#subobject:{{{event}}} 
  |Has event={{{event|}}}
  |Has event start={{{start|}}}
  |Has event end={{{end|}}}
  |Has event type={{{type|}}}
  |Has event location={{{location|}}}
  |Has event icon={{#switch: {{{type|}}}|Meeting =File:Event-meeting-icon.png|Presentation=File:Event-presentation-icon.png|Talk=File:Event-talk-icon.png }}
  |Has event color={{#switch: {{{type|}}}|Meeting=#E9AF32|Presentation=#A0D8F1|Talk=#BF381A|Party=#E07628 }} 
  |Has event description={{{description|}}}   
 }}

Here is some important information about this template. You'll note that this template starts with {{#subobject:{{{event}}}, which will create the subobject with a name, set to the name of the event. If you instead remove the {{{event}}} from this line, so it reads {{{#subobject:, then it will create an anonymous subobject with a pre-generated name that is a hex hash code. This will also work, but will cause events on the EventCalendar to display as "PageName#HashCodeHere" which may not look as nice as "PageName#Event Name Here". As I learn how to tweak the EventCalendar display to improve event name display, use of the anonymous hash code as the subobject name may be preferable.

Displaying a Calendar

To display a calendar of events, what you do is write an inline semantic query using the {{#ask:}} parser function, and specify format=eventcalendar. Let's look at an example query:

{{#ask:[[Has event::+]]
  |?Has event
  |?Has event start
  |?Has event end
  |?Has event description   
  |?Has event icon            
  |?Has event color
  |?Has event location
  |format=eventcalendar
  |start=earliest            
  |defaultview=month
  |limit=   
  |link=subject
  |legend=pane
  |firstday=Monday
  |dayview=yes
  |headers=show
  |theme=vector
  }}

Let's walk through the various parts of this query. On the first line, the [[Has event::+]] will peform a query for all pages (or in our case, subobjects) that have the semantic property Has event defined. Next, there are several lines that begin with | ? -- these lines specify semantic properties that the EventCalendar result format needs to display the calendar. The order of these properties, not the name, is important, so if you desire to use different property names in your template, be sure to use the new names here too. Just remember that the EventCalendar result format will want to see an event name, followed by an event start date, followed by event end, then a description, etc.

Below the property name definitions, the output format is set to eventcalendar, and the following lines in the query are parameters that are passed to the EventCalendar result format display. They are defined on the EventCalendar format Help page.

Example Event

Here is an example call to the Event template, defined above:

{{Event 
  |event=My special event
  |start=01 May 2014
  |end=02 May 2014
  |type=Presentation
  |location=Albert Hall
  |description=Good times
 }}

Scratch Space

Event

Event
Massa ac metus porttitor neque
Type
Presentation
Location
Albert Hall
Start
01 May 2014
End
02 May 2014
Description
Massa ac metus porttitor neque vitae purus quis ac enim semper. Habitasse tempor sit tortor id quis congue porta lacinia cursus justo. Justo accumsan orci estab

{{#subobject:Massa ac metus porttitor neque |Has event=Massa ac metus porttitor neque |Has event start=01 May 2014 |Has event end=02 May 2014 |Has event type=Presentation |Has event location=Albert Hall |Has event icon=File:Event-presentation-icon.png |Has event color=

  1. A0D8F1

|Has event description=Massa ac metus porttitor neque vitae purus quis ac enim semper. Habitasse tempor sit tortor id quis congue porta lacinia cursus justo. Justo accumsan orci estab }}


{{#ask:Has event::+ |?Has event description |?Has event start |?Has event end |?Has event description |?Has event icon |?Has event color |?Has event location |format=eventcalendar |start=earliest |defaultview=month |limit= |link=subject |legend=pane |firstday=Monday |dayview=yes |headers=show |theme=vector }}


__SHOWFACTBOX__ Email::drobbins@funtoo.org