The Serendipity Handbook

You can now read the (german) handbook here: PDF - https://github.com/s9y/Book (LaTeX source).

Forum-Information

Before posting about errors, make sure that the answer cannot already be found in our FAQ or by searching this forum!
Posting is restricted to registered users (registering is free and simple!) due to recent spam attacks. When having trouble with this board, contact garvin(-at)s9y(-dot)org.

Board index Plugins Research Blogging / Quellenverweise

Creating and modifying plugins.
Jigger
Regular
 
Posts: 10
Joined: Thu Dec 15, 2011 5:17 pm

Postby Jigger » Thu Dec 15, 2011 5:32 pm

Hi,

I'm not sure which language is best to be used here, so I write in English (but I do also understand German).

I am very interested in doing some research blogging. But this would mean that I need some elegant way to incorporate references in my blog, like wikipedia (mediawiki) does. Also I have seen this on http://www.scienceblogs.de/. I know that this an entirely different blogging system, but I am very fond of s9y.

This basically means that I include some sort of Markup in the blog-article and from this, a reference on the bottom will be created...

  • So is there a way to build a plugin for this purpose?
  • Is anyone else interested in a plugin like this?

User avatar
garvinhicking
Core Developer
 
Posts: 29521
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany

Postby garvinhicking » Thu Dec 15, 2011 7:28 pm

Hi!

The technical aspect of this wouldn't really be too hard. The question would more likely be, how would you like to write those references and maintain them?

I don't have a good idea on how to write this in a blog entry most easily - what I found is a jquery solution like this: http://jsfiddle.net/6A8nX/

But the markup for that seems like much maintenance work.

If you had an idea how to format it, I think I could easily patch up a plugin for this..

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

Jigger
Regular
 
Posts: 10
Joined: Thu Dec 15, 2011 5:17 pm

Postby Jigger » Thu Dec 15, 2011 8:03 pm

Hey Garvin,

thanks for the quick reply.

I have to possibilities in mind. But for either possibility the plugin should check for references in the article. If a reference-tag is found, a section should be displayed (like trackbacks and comments) for the references. These references should be numbered and linked, like this:
The earth is round²

=== References===
1. blabla
2. Galileo, long long time ago

Now to the two ideas
  1. Quick & Dirty:
    The QD-Way would be kinda like the multi-lang and the mediawiki solution. Markup could be like this:
    Code: Select all
    {{ref}}Mustermann 2008, Musterbeispiele am Mustercode, doi:blablabla{{/ref}}
    Down in the part where the reference will be displayed, it just shows a copy of the text above. I believe this to be rather simple.
  2. The Management Way:
    This would include some kind of DB. In the back-end you can store all your references. Every single reference gets a key. So in the Mustermann example the key could be "Mustermann2008". Now if I call the reference to the key "Mustermann2008" the plugin will catch the reference from the DB and place it in the reference section. (This is how latex reference managers work too.) This is rather tricky but it would probably also boost the s9y-fanbase, since no other Blog-Software hast this incorporated, afaik.
Version two would basically need an extendable backend with 2 input-boxes, one for the reference and one for the key.

The QD way would be fine of course but the M way would be really awesome ;)

User avatar
garvinhicking
Core Developer
 
Posts: 29521
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany

Postby garvinhicking » Thu Dec 15, 2011 8:57 pm

Hi!

I thin 1&2 could also be combined. The plugin would parse the blog entry, check for all references. If it finds a new one, it inserts it into the database - if it exists, it fetches the description from the database.

Now in future entries, whenever a reference key is used again, it would fetch the original description. Or if a custom description in the blog entry is given, it would use that one instead of the generic one.

A management interface would show all stored refreences and allow to update their text without needing to edit the corresponding blog entry.

Also, in the blog entry editor a tag-like input box could show all existing references so that they could be easily inserted into the entry.

How does that sound? Should not be too hard to create.

However I wonder which markup would be good {{ref}} is IMHO a bit hard to type; is that really the wikimedia syntax? If so, we should definitely use that instead of invent our own. Is ":" the real separator? I'd imagine that ":" occur multiple times inside a reference, is only the last ":" then a separator?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

Jigger
Regular
 
Posts: 10
Joined: Thu Dec 15, 2011 5:17 pm

Postby Jigger » Fri Dec 16, 2011 12:32 am

Hi,

in mediawiki pseudo-html is used, you can find it here.
There are two ways to use it: <ref>E. Miller, The Sun, (New York: Academic Press, 2005), 23-5.</ref> for an "one-time" reference. and <ref name="multiple">Multi-Ref</ref> if a reference is used several times. Then you place <references /> where you want the references to show up.

Now for the part with the references. A lot of the references have just plain text like the first <ref> up there. But a lot of papers can be referenced to with a link or a doi.
In einer Publikation, die durch einen DOI identifiziert ist (z. B. doi:10.1371/journal.pbio.0020449), können weitere DOI wiederum Teile identifizieren; so ist im angegebenen Beispiel eine Abbildung zu finden mit doi:10.1371/journal.pbio.0020449.g001. Dies findet man besonders oft bei Artikeln in einem Journal oder Kapiteln in einem Buch. Man kann aber nicht allgemein davon ausgehen, dass man eine DOI an einem Punkt oder Schrägstrich kürzen kann, um zu einem derartigen „übergeordneten Objekt“ zu gelangen, da es hier kein festes Schema gibt.

So possible references look like:

A comma is the normal separator. A dot is the end, but you have to take into account that some people will not know or use the "correct" way to cite...

I have to say a combination of both would be shear awesome...

User avatar
garvinhicking
Core Developer
 
Posts: 29521
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany

Postby garvinhicking » Fri Dec 16, 2011 1:59 pm

Hi!

I just tried to get this kickstarted, implemented in the serendpity_event_wikilinks plugin:

https://github.com/s9y/additional_plugi ... _wikilinks

The syntax is described in the plugin configuration and works like:

Code: Select all
I will make a reference to Serendipity<ref name="s9y">Best blog ever</ref> here and it will get shown at the end.


The reference is parsed, and if a name=XXX attribute exists, it's stored in the database for later referencing in other blog entries like this:

Code: Select all
Hey, another cool thing about Serendipity<ref name="s9y"></ref> is this: You can...


Which will automatically fetch the description of "Best blog ever" from the database, so you can uniquely assign that.

Please have a try. :)

(Everything within <ref> is parsed as HTML, so you can put any HTM links in there. I found the wiki style markup for links at that place misleading, also it should be taken care of if you use wikimarkup plugins in s9y, and just take care you put them before the wikilinks plugin)

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

User avatar
Eni
Regular
 
Posts: 62
Joined: Thu Jan 27, 2005 11:47 pm
Location: Münster, Germany

Postby Eni » Fri Dec 16, 2011 10:22 pm

Jigger wrote:Is anyone else interested in a plugin like this?


Yes!

I want to use my blog as study and work portfolio, so I was looking into "footnotes" as well. It didn't even came to my mind that this could be easier done via a plugin, my plan was to just do it manually per entry and put interesting sources into an external link management system.

About the idea with the automatic references database... I start my Master studies next year and a e-portfolio is one of the module exams. With a automatic footnote system like this, I could basically use a s9y install as a digital äquivalent to a proper thesis paper. It would be especially great if the references could be tagged with a category and displayed on a overview page - would that be possible?

Let's say, my portfolio is about Social Work, and I have entries of different work fields (they're not blog categories!):
* Streetwork
* Family Therapy
* Children & Youth

Would it be possible to tell my reference database to sort the references like this? So that I'm able to display e.g. all the references of 'Streetwork' on one static page for overview, maybe even with small links back to the entries where they're used?

Or is this way too much work and I'm dreaming ahead of my myself? :lol:

I'm sorry, I was just spinning ahead of what's possible with a plugin for automatic scientific references.

~eni
Sorry, I'm Late. But I Got Lost On The Road Of Life.

User avatar
garvinhicking
Core Developer
 
Posts: 29521
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany

Postby garvinhicking » Fri Dec 16, 2011 10:29 pm

Hi Eni!

Hhm, your references sound more like tagged entries to me? Maybe you could provide more precise examples on what you actually want to achieve - generally of course, once a reference is stored in the database, you can join it with any other metadata of the entry to generate overview pages.

Currently however my modified plugin only tracks a reference for the first entry that it is used in. All other entries that use a reference are not stored within the database (because in the references it would be an overhead to have them there, since the table holds actual references, not references to references. *g*)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

User avatar
Eni
Regular
 
Posts: 62
Joined: Thu Jan 27, 2005 11:47 pm
Location: Münster, Germany

Postby Eni » Fri Dec 16, 2011 10:58 pm

Hi Garvin,

yes, I always spin things a bit ahead of me and my own abilities :mrgreen:

I basically was thinking of how a normal thesis paper is build up:

First, you have the individual pages with numbered words¹ and on the bottom the footnotes².

--------
¹ Duden: Substantiv, Neutrum - kleinste selbstständige sprachliche Einheit
² which explain the numbered words shortly or short-reference the source, in a small size


.... this would be the blog entries.

Then, at the end of the thesis, you have the literature list in which everything is listed properly, often categorized by importance (main, secondary, supporting) when there is a lot to list. In a blog, there will be a lot to list so it makes sense to think about categories/tags for the references if one want to display them in an overview, I think.

So when you display all references on a static page, they would be sorted and not chaotic. In my case, all references regarding Streetwork would be together, all references regarding Family Therapy would be together, ect. That's basically all I meant with "tagging" the references. If there are no such tags, the reference overview would become extremely chaotic in the long run. I could even create a "literature" link in the menu bar and sort the references into tag-related subpages. Though, this is only an issue if an overview is wished in the first place, of course - I would want it.

The other thought then was to be able to click on a reference in that overview and have all entries listed in which it is used. But that's probably a bit much asked for and maybe only interesting for a small number of users now that I think about it ^^;

~eni
Sorry, I'm Late. But I Got Lost On The Road Of Life.

User avatar
garvinhicking
Core Developer
 
Posts: 29521
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany

Postby garvinhicking » Fri Dec 16, 2011 11:47 pm

Hi!

In that case I would suggest you to use tagging on entries themself to classify. Those classifications would also apply to the references used within, and with those two informations in the database we can later build an overview that fetches referenced based on the tag the reference is associated in.

Adding a third parameter to references (reference key, reference content, reference tag) would make the parsing quite complicated. Currently only <ref name="xxx"> is supported, that's easy to parse with a regular expression. <ref name="xxx" tag="yyy" would be quite harder, because people could also change the order of name and tag, and that would require much more parsing overhead for all variants...

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

User avatar
Eni
Regular
 
Posts: 62
Joined: Thu Jan 27, 2005 11:47 pm
Location: Münster, Germany

Postby Eni » Sat Dec 17, 2011 5:13 am

Hi!

That certainly makes sense. I'm not a big fan of using entry tags but this would be actually a good usage for them.

I'm starting to work in an e-tutoring project in February in which I will need an e-portfolio and I would very much love to setup a s9y for this, especially when a footnote/source plugin would allow me a certain scientific standard. I'm looking very much forward to try this plugin out ^__^

~eni
Sorry, I'm Late. But I Got Lost On The Road Of Life.

Jigger
Regular
 
Posts: 10
Joined: Thu Dec 15, 2011 5:17 pm

Postby Jigger » Sun Dec 18, 2011 2:23 pm

Hi again,

I'm testing it right now and one problem could be, that it gives back a mysql-warning when I use a reference twice in an article.
Warning: mysql_fetch_array() [function.mysql-fetch-array]: The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH. in Serendipity/include/db/mysql.inc.php on line 127


By the way, how can I include the reference over smarty?

User avatar
garvinhicking
Core Developer
 
Posts: 29521
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany

Postby garvinhicking » Sun Dec 18, 2011 5:31 pm

Hi!

That was a bug of the plugin, I mixed ", 'assoc', true" with ", true, 'assoc'". Plugin is updated now.

With smarty the plugin config should mention the smarty variable, and theres a config option you need to set to "-". You can use {foreach} or implode or whatever you like on that array; check {$entry.properties.references|print_r} for its structure.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

Jigger
Regular
 
Posts: 10
Joined: Thu Dec 15, 2011 5:17 pm

Postby Jigger » Sun Dec 18, 2011 9:04 pm

Hey Garvin

garvinhicking wrote:That was a bug of the plugin, I mixed ", 'assoc', true" with ", true, 'assoc'". Plugin is updated now.

Still gives the same error if I use:
Code: Select all
Dies ist ein Test <ref>Testläufe sind wichtig!</ref> und dies ist ein zweiter Test <ref name="Testlauf">Flausch</ref>. Der nächste des geht um die wiederverwertung von Referenzen<ref name="Testlauf"></ref>.

(Although I updated it)
garvinhicking wrote:With smarty the plugin config should mention the smarty variable, and theres a config option you need to set to "-". You can use {foreach} or implode or whatever you like on that array; check {$entry.properties.references|print_r} for its structure.

I played around with {$entry.properties.references|print_r} and foreach but it says that the array is empty, I think... (With and without MySQL-warning)

Kind regards,
Jigger

User avatar
garvinhicking
Core Developer
 
Posts: 29521
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany

Postby garvinhicking » Mon Dec 19, 2011 12:38 am

Hi!

How did you perform the update? Check your serendipity_event_wikilinks.php file, every serendipity_db_query() call should now use serendipity_db_query(QUERY, true, 'assoc') and never serendipity_db_query(QUERY, 'assoc', true)...?!

I played around with {$entry.properties.references|print_r} and foreach but it says that the array is empty, I think... (With and without MySQL-warning)


Did you try a {$entry.properties|print_r} to see what else is there? You did place that code inside entries.tpl within the second foreach loop?

I'm sure we'll get this resolved :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

Next


Return to Plugins

Who is online

Users browsing this forum: No registered users and 2 guests

cron