@Friendica Theme Developers
One of the many things which are not that good solved in friendica is from my point of view that fact that all objects which belong to a post are saved as bbcode in the item body. With objects I mean something like shares, attachments, events and so on. Since the beginning of using friendica I very unsatisfied that there are only limited possibilities to theme such objects because they are hard-coded. While I tried to fix https://github.com/friendica/friendica/issues/2646
some time ago I started to do some experiments how to extend the possibilities for displaying events.
Before I continue polishing and finishing the could I would like to have some feedback. There are some questions in my head and some (lets call it) designing decision to do (or which I have done and needs to discussed).
You will find the present code at https://github.com/rabuzarus/friendica/tree/20170904_-_extend_event_html
and an example frio event at https://test.kommune4.de/display/9fd9b54c1359dcc60b622dd589375790
To explain what the code does:
In a short, the activity stream object (the one which is saved in the item
table in the object
column) will be extended with information which are needed for the event (e.g. start time, end time, author, location and so on). (I saw this in the hubzilla project and I like the idea to make more use of the object field if there are embedded object in the posts - events, share, attachments and so on).
While frindica does the preparing of the item for displaying its content, it verifies if the event item is an event and if the event object
does contain additional data (for compatibility reasons with older objects). If it is an an event object
it will extract the event data from the event object
and will format this data in a special event template. The template formatted output will replace the existing $item['body']
So every theme can decide how an event should be presented in the network stream.
To improve the speed, friendica does cache the html of an item. This would mean that we would need to parse the event everytime when a user would change the theme (and the event template would be a different one). To solve this only the event description (the part which should not change when selecting a different theme) is saved in the event cache.
There are some parts I want to talk about with you.
1.) I'm not sure if you like this approach (it was inspired by the hubzilla project)
2.) The created event object
- <title>Friendica Hackathon</title>
- <startTime>2017-11-24 15:00:00</startTime>
- <endTime>2017-11-26 19:00:00</endTime>
- <description>Hackathon in Berlin to prepare the 3.6 release of Friendica.[url=https://friendica.kommune4.de/search?tag=xD]xD[/url];
- Room is limited, so please let us know if you plan to join us in Berlin.</description>
- <name>Jugendclub [url=http://zope2.in-berlin.de:8100/wsb/elok]E-LOK[/url]</name>
- <address>Laskerstra&#[url=https://friendica.kommune4.de/search?tag=xDF]xDF[/url];e 4-6, Berlin</address>
- <content>[event-summary]Friendica Hackathon[/event-summary][event-description]Hackathon in Berlin to prepare the 3.6 release of Friendica.&#[url=https://friendica.kommune4.de/search?tag=xD]xD[/url];
- Room is limited, so please let us know if you plan to join us in Berlin.[/event-description][event-start]2017-11-24 15:00:00[/event-start][event-finish]2017-11-26 19:00:00[/event-finish][event-location]Jugendclub [url=http://zope2.in-berlin.de:8100/wsb/elok]E-LOK[/url]&#[url=https://friendica.kommune4.de/search?tag=xD]xD[/url];
- [map]Laskerstra&#[url=https://friendica.kommune4.de/search?tag=xDF]xDF[/url];e 4-6, Berlin[/map][/event-location]</content>
- <link rel="alternate" type="text/html" href="https://test.kommune4.de/display/9fd9b54c8359dcc61152d76696294856"/>
- <name>Ronny Rabuzarus</name>
- <link rel="alternate" type="text/html" href="https://test.kommune4.de/profile/rabuzarus"/>
- <link rel="photo" type="image/jpeg" href="https://test.kommune4.de/photo/58c7a30eeacc6492c43daf582cfb3cba-5.jpg"/>
I'm unsure about the used tag names startTime
. The naming was taken from https://github.com/activitystreams/activity-schema/blob/master/activity-schema.md#event
. (should we use it or should we rather use the friendica names start
or should we use rather other tag names - e.g. hubzilla usesdtstart
3.) Because I'm not familiar with xml handling in php I extended xml::from_array( )
to handle nested arrays. In addition I extended xml::to_array( )
to have a 'mixed' (Please: If some one does have a better name for this mode, please let me know) priority mode. It does convert xml in the following way: http://www.lalit.org/lab/convert-xml-to-array-in-php-xml2array/
In addition I changed the behavior of xml::to_array( )
in 'attribute' priority mode a little bit. Formerly the
Now it @value
represents the content of a xml element:
[@value] = http://irgendwas.de
I did some tests to convert a xml with xml::to_array( )
and back with xml::from_array( )
. The results look very good (Note this only works if the the array is created in 'attribute' or the new 'mixed' mode). I did several tests but I couldn't be sure if it doesn't break something (@Michael Vogel
can you have a look - sry for disturbing your holiday).
4.) For frio I create short naming versions for the month and the day (eg. Mon, Tue and so on or Jan, Feb, Mar) in format_event_object( )
. This code for this is inspired by other places in friendica where dates are created. I'm not familiar with date/time formats of other countries so this was the best way of preventing doing some mistakes. If anybody does have better solutions of solving this he/she is welcome to tell me.
5.) I have thought about creating a template for the content of function format_event_html()
. But since this function is also used in function bbcode( )
I can not estimate the effects of having the possibility of different templates. Any thoughts about this?
Maybe I have other questions but I can't remember it at the moment. So I will end at this point and hope about some feedback