Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

+ wikipedia (en), small update to picplz #90

Merged
merged 3 commits into from

2 participants

Armin Roșu Christian Vuerings
Armin Roșu
Collaborator

Wikipedia (English only)

Added support for wikipedia contributions, english language only. Wikipedia Api Reference

By default 10 contributions are returned, but that number can be configured. Thinking of setting it to the lifestream count.

The API doesn't return a url for the contribution. It would be possible to get it, but that would require another API call, so I chose to simply replace spaces with underscores in the title, since this is the way wikipedia generates urls anyway (afaik).

The username used in the example has the highest number of edits on wikipedia.

Maybe should add a setting for the chosen language …

Picplz

Previously picplz streams were linking to the 640px wide image. Changed this to link to the picture page, so one could interact with the user as well.

arminrosu added some commits
Armin Roșu arminrosu picplz link to photo page, not image
Previously picplz streams were linking to the 640px wide image. Changed
this to link to the picture page, so one could interact with the user
as well.
bf4ce3b
Armin Roșu arminrosu +wikipedia (English)
Added support for wikipedia contributions, english language only.
[Wikipedia Api Reference](http://www.mediawiki.org/wiki/API:Query)

By default 10 contributions are returned, but that number can be
configured. Thinking of setting it to the lifestream count.

The API doesn't return a url for the contribution. It would be possible
to get it, but that would require another API call, so I chose to
simply replace spaces with underscores in the title, since this is the
way wikipedia generates urls anyway (afaik).

The username used in the example has the highest number of edits on
wikipedia.

Maybe should add a setting for the chosen language …
7a2e847
Armin Roșu arminrosu missed a comma :( 4eba4fe
Christian Vuerings christianv merged commit 4eba4fe into from
Christian Vuerings
Owner

Hi Armin,

Thanks for your contribution.
Everything merged in nicely.

Armin Roșu
Collaborator

Excellent! What do you think about adding the language setting and using the lifestream count to set the number of contributions?

Christian Vuerings
Owner

Sounds fine to me, so you have something like this in mind?

{
  service: 'wikipedia',
  user: 'Koavf',
  limit: 5,
  language: 'en'
}
Armin Roșu
Collaborator

Actually, only:

{
  service: 'wikipedia',
  user: 'Koavf',
  language: 'en'
}

The limit I can get from config._settings.count. I am just wondering how wise that would be, since it could mean a pretty large file ...

Christian Vuerings
Owner

You're right, I would leave the limit/count out for now, as we do with other services.
Does that sound OK for you?

The language option is a nice feature though and should default to en if none is given.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 14, 2011
  1. Armin Roșu

    picplz link to photo page, not image

    arminrosu authored
    Previously picplz streams were linking to the 640px wide image. Changed
    this to link to the picture page, so one could interact with the user
    as well.
Commits on Oct 15, 2011
  1. Armin Roșu

    +wikipedia (English)

    arminrosu authored
    Added support for wikipedia contributions, english language only.
    [Wikipedia Api Reference](http://www.mediawiki.org/wiki/API:Query)
    
    By default 10 contributions are returned, but that number can be
    configured. Thinking of setting it to the lifestream count.
    
    The API doesn't return a url for the contribution. It would be possible
    to get it, but that would require another API call, so I chose to
    simply replace spaces with underscores in the title, since this is the
    way wikipedia generates urls anyway (afaik).
    
    The username used in the example has the highest number of edits on
    wikipedia.
    
    Maybe should add a setting for the chosen language …
  2. Armin Roșu

    missed a comma :(

    arminrosu authored
This page is out of date. Refresh to see the latest.
1  css/lifestream.css
View
@@ -27,6 +27,7 @@
.lifestream-tumblr { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6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zkhmgThUb4WZrOHl7EVifqu0v72/xba9xipDYENhfEZjf0lngyg0QkpohDRQajVRax82TUtphd/f4+vu8yg/WAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACQ5xMIAAABvdFJOU///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AP5WdtUAAADmSURBVHjaVMxHV8JgEIXhMYEkgkiTKlLEjr2LIlhQsWEDAbvmC9HM5P8vnaiHc3x391lcsOlfNpBqGEb/119vI0C7IV3Xr/Dy1xn8/lL2AVE4XmkOAHm9H/VHxOXNm2w7EGB4T6fxp8Xzo7vyMJA2e3IwjxiPz63dbj8xAMjXU/xRuz/LRaMNILc7JY3hggBZljVtAugiGQy2CpZglySYBIqMxmKvlhVOHo8nEjODQL58sfNsOVUPd1YYFEVZn97g/bLq8URcQN0h0zRPl8JC7O9t+RjUTKbr5LipusD+7NXH2d8CDAAuS0MoB+LPtAAAAABJRU5ErkJggg==);}
.lifestream-twitter { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAABGdBTUEAALGPC/xhBQAAADBQTFRFAAAA/f38RtD+5fX7+P39g9Ly7/v91/H5/v7+////mOXrwu/zRcXyXcz1r+vwM8z/LZKJ8gAAAAF0Uk5TAEDm2GYAAAB8SURBVAjXY2C9CwYBDKHby4GgOpTh9u6U7HfvXu9luP1k/5N3794BGS/+/4Axfna07AMyVv7///9f1h6G0yDGf6m9EAZU5OfM5ld7GM6t/P95RturNwznlugDpayAjGXrgYq8gIxV8/SBImsY7q7b1jmjbd9dBt4zYHABAAG7YAbUnzIdAAAAAElFTkSuQmCC);}
.lifestream-vimeo { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAABV0RVh0Q3JlYXRpb24gV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mUHvbV/I3V5f+chaVQ5POKGm/cnrbfg7NIdgYgnJbA6brRvwLJuHUa/Dga2tfqYh2iVm4KO7//n93puZM/uaMvHFZeRWi+qhxXOARleFoakYNRQwm1zCF++9ljnR158lzY9My6/NRM+MlJo79vXV2MltlkBBBqalReiN61FjqYOUk1lLosNuChz/9maEcUlzlgnVWWDD9FP3djSc/U4dpoNOm/fd9hbdTsfLNkbyBJ6EfxmdXrztC7vZMAUvfHjx+OUHz4eJ9Q6hnPULwVjh3O2qcHUeEQ0mVyGdsKgjW1H5uJB6NpmeHLqW9g1PUoi1ZIqQ+U+AAQBxOVz5xw02pQAAAABJRU5ErkJggg==);}
.lifestream-youtube { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAAHVQTFRFAAAA1/v+/+/v9eas9eWs/9LT/9LS/9HS/8/PocXiosXi/7u6/7Sy1a5x8av8/5ubZorGZ4rHnnAcRmirRWeq/1hPgUoR/9rZ/7q61a5w/5qaupJL9uat/1hO/1dO8CQA1/v9/ysN8SQA/ysOAAAA/yoN////MKUSUgAAAAF0Uk5TAEDm2GYAAACSSURBVBjTVY6HEsIwDEPN3pTdFroSW/r/T8ShlB66nM95khOLlA/ethwkQtrROMpBaRu+7ESj9WBm3dwv3Q9U1lUJXCYj8JEzD3btwb8khyoCFL1ygVMEhZfgBgRgcpXfiLhXM7AhC91NV5AwAPBJLlU83Di4f4CmN5R1QTZr7pFx4Yk2xtimk5oIkbSCBgyfvAGqWiEukoSMuwAAAABJRU5ErkJggg==);}
.lifestream-facebook_page { background-image: url(data:image/png;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5Ojf/2wBDAQoKCg0MDRoPDxo3JR8lNzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzf/wAARCAAQABADASIAAhEBAxEB/8QAFAABAAAAAAAAAAAAAAAAAAAABv/EACEQAAMAAQQCAwEAAAAAAAAAAAECAwQABQYRElEUIUFx/8QAFQEBAQAAAAAAAAAAAAAAAAAABAX/xAAZEQADAQEBAAAAAAAAAAAAAAABAhEAEjH/2gAMAwEAAhEDEQA/ADsI0tVIwmz0chURB2WP4ANK+Qcexto41iUfbM45t5JSuUxInBiR2jL7++ho9jRM2lkQz5SopDoysQyn8IPvSXmG5Nm7XtMU3lbKuEvypivl50HR7Ye/7qw5PSzzCWQ7/9k=);}
4 example.html
View
@@ -196,6 +196,10 @@
user: 'denbuzze'
},
{
+ service: 'wikipedia',
+ user: 'Koavf'
+ },
+ {
service: 'wordpress',
user: 'pixartimes'
},
2  src/services/picplz.js
View
@@ -22,7 +22,7 @@ $.fn.lifestream.feeds.picplz = function( config, callback ) {
date: new Date( ( item.date ) * 1000 ),
config: config,
html: $.tmpl( template.uploaded, {
- url: item.pic_files["640r"].img_url,
+ url: 'http://picplz.com' + item.url,
title: item.caption || item.id
} )
});
47 src/services/wikipedia.js
View
@@ -0,0 +1,47 @@
+(function($) {
+$.fn.lifestream.feeds.wikipedia = function( config, callback ) {
+
+ var template = $.extend({},
+ {
+ contribution: 'contributed to <a href="${url}">${title}</a>'
+ },
+ config.template);
+
+ $.ajax({
+ url: "http://en.wikipedia.org/w/api.php?action=query&ucuser="
+ + config.user + "&list=usercontribs&ucdir=older&format=json",
+ dataType: "jsonp",
+ success: function( data ) {
+ var output = [], i = 0, j;
+
+ if(data && data.query.usercontribs) {
+ j = data.query.usercontribs.length;
+ for( ; i<j; i++) {
+
+ var item = data.query.usercontribs[i];
+
+ // Fastest way to get the URL.
+ // Alternatively, we'd have to poll wikipedia for the pageid's link
+ item.url = 'http://en.wikipedia.org/wiki/'
+ + item.title.replace(' ', '_');
+
+ output.push({
+ date: new Date( item.timestamp ),
+ config: config,
+ html: $.tmpl( template.contribution, item )
+ });
+ }
+ }
+
+ callback(output);
+ }
+ });
+
+ // Expose the template.
+ // We use this to check which templates are available
+ return {
+ "template" : template
+ };
+
+};
+})(jQuery);
Something went wrong with that request. Please try again.