Mephisto Pagination Plugin updated: what's new?
posted: October 11th, 2007 · by: Sven
Like I mentioned an updated version of the Mephisto Paged Article Lists plugin is available in the Subversion repository. You can grab this awesome stuff right here: http://svn.artweb-design.de/stuff/mephisto/mephisto_paged_article_list
Like with the Inverse Captcha Plugin some more information about the new version of this plugin are due, too. So, what’s new here?
Let me first mention that the plugin now pages tag pages, which I have been asked for by some people. This stuff will just work like expected.
Also, it’s worth noting that I am running my blog on Mephisto edge on Rails rev 7405 (i.e. that’s Rails edge as of some weeks ago, it’s not the Rails 2.0 release candidate!). I have neither tested this with Mephisto 0.7.3 on Rails 1.2.3 nor Rails 2.0 yet. The will_paginate plugin works on Rails 1.2.3 and most probably will work on Rails 2.0, so IMO there’s no obvious reason why the Mephisto Paged Article Lists plugin shouldn’t do so as well. But I can’t garantuee anything like that. Please post your results in the comments if you happen to check this out!
Ok, with this out of the way, let’s look at interesting stuff.
Now riding (a liquidized) will_paginate
You most probably know that Rails edge has kicked pagination as a built-in core feature and now requires us to choose from a variety of plugins to get this functionality. This really is a good thing. But of course it means that we have to re-integrate a plugin in our applications.
Rick chose will_paginate as the pagination solution that is shipped with Mephisto right out of the box now. Therefor the most obvious solution was to refactor my plugin to now rely on will_paginate, too.
To get will_paginate working from within Liquid templates I needed to do some wicked trickery though with the WillPaginate::Collection, which I guess probably deserves an article on its own. But in short the Mephisto PagedArticleList plugin now basically does the following:
- It registers a before_filter which extracts the page parameter from the url path. (This is necessary because of Mephisto’s dynamic routes mechanism.)
- It replaces the MephistoController actions dispatch_list and dispatch_tags with versions that assign paginated collections to the template.
- It adds a to_liquid method to the WillPaginate::Collection and provides a new WillPaginate::CollectionDrop to be able to access the collection from within the template accordingly.
- It registers a series of filters to Liquid in order to allow you to use the paginated collection from within your templates.
That’s it.
All you need to know though is that you can choose from the following Liquid filters:
Prev/next page links
Like before, there’s a convenient prev_next_page_links filter that provides prev/next links like those you can see on this blog. Here’s a screenshot:

The usage of this filter has slightly changed because of the WillPaginate collection that we are now using. You can now do:
{{ articles | prev_next_page_links: path_info }}
You can also provide two alternative link texts and/or a separator to this filter. I.e. the following usages will work as expected:
{{ articles | prev_next_page_links: path_info, 'previous', 'next' }}
{{ articles | prev_next_page_links: path_info, 'previous', 'next', '·' }}
{{ articles | prev_next_page_links: path_info, '·' }}
Single link filters
Probably you might want to control these links individually. You can then (like before) use the following filters:
{{ articles | link_to_prev_page: path_info }}
{{ articles | link_to_next_page: path_info }}
Again, you can inject a different link text. Like so:
{{ articles | link_to_prev_page: path_info, 'previous' }}
{{ articles | link_to_next_page: path_info, 'next' }}
Digg-style navigation
As we are riding on the back of will_paginate, only some minor additions were necessary to enable the usage of the will_paginate view helper from within our Liquid templates. That means that now you can do this:
{{ articles | will_paginate: path_info }}
… which will result in a nice list of pagination links. You can now easily add some CSS styles (e.g., like the stylesheet proposed here) and achieve something that looks very similar to the paginators on Digg, Flickr and others.
Probably something like this:

What do you think?
Hank said October 27th, 2007 at 10:44 AM ¶
Bah - New Mephisto / Edge Rails broke your stuff. I just get Liquid type conversion errors now. I don’t really know where to look in your code to debug, and production.log isn’t being helpful. Reproduce by upgrading mephisto trunk and freezing edge rails.
Ashley Moran said October 28th, 2007 at 01:40 PM ¶
Was just about install this then I saw Hank’s comment. Think you will be able fix this one Sven? I’d like pagination on my blog, the index page is getting a bit unwieldy.
Sven said October 30th, 2007 at 06:14 PM ¶
Hank,
I’m not sure what’s version you installed as Edge Rails. When I try to freeze to the current Edge Rails without any further version specified, I’ll not even get mongrel started. (Following the rails-core list I believe this is because they messed with routes and Mephisto’s own routing won’t work with this.)
I have just updated my locale setup to Mephisto rev3009 (which is the current trunk) and froze Rails to TAG_rel_2-0-0_PR. I commented out Mephisto’s dependencies on ActionWebService (I don’t use the XMLRPC api anyways) and everything’s working like a charm.
If you encounter any Liquid errors and don’t know how to debug them, in Mephisto it’s helpful to change lib/mephisto/liquid/liquid_template.rb like this:
This prevents Mephisto to swallow Liquid errors.
Sven said October 30th, 2007 at 06:32 PM ¶
Ashley,
I don’t think there’s a serious problem with the plugin. I’m locally running the same setup you’ve described on your blog and everything’s fine.
Ashley Moran said November 4th, 2007 at 12:05 AM ¶
You’re right Sven, it works fine now
Ryan said November 17th, 2007 at 11:55 PM ¶
I have been trying to get this to work for a couple of hours. I don’t get any errors, where I add:
{{ articles | prevnextpagelinks: pathinfo }}
I get :
#
Sven said November 18th, 2007 at 09:12 PM ¶
Hey Ryan,
actually these are error messages like they are produced in Liquid templates (look at the HTML source code of your page, you’ll see something more than the # marks, nothing really informative, though).
To find out more about the errors you can modify lib/mephisto/liquid/liquid_template.rb so that the errors don’t get caught by Liquid. See the patch that I’ve given some comments above, it’s actually just a single ! character added.
Ryan, from your comment I’ve got really no clue about the problem. You might be running an old version of Mephisto or Rails or something? (Look here for some hints on working versions: http://www.artweb-design.de/projects/mephisto-plugin-paged-article-lists) If you can’t figure it out yourself just drop me an email with some kind of error backtrace and info about your system and I’ll see if I can help.
Steph said November 20th, 2007 at 03:37 PM ¶
Hi,
I have installed this plugin with : script/plugin install http://svn.artweb-design.de/stuff/mephisto/mephistopagedarticle_list
But when I restart mongrel, I have this error :
NameError (uninitialized constant WillPaginate::Collection)
Do you have an idea ?
Thanks.
y0rtz said November 28th, 2007 at 07:27 PM ¶
Hi Steph, i was running the same error message as specified by you:
NameError (uninitialized constant WillPaginate::Collection)
when i was trying to enter my admin section and browse a section.
Actually i was able to fix this by installing will paginate plugin.
http://errtheblog.com/post/4791
Actually everything works fine on my mephisto install, except the fact that i wasted an entire afternoon trying to figure out how to use the plugin (i am talking about the pagination plugin from Sven).
Thanks for your precious work man, but i find it really whimsical to understand how to use it properly.
From what i got from your wiki it seems you just need to add those filters.
When i try to add those liquid filters into my layout, nothing happens.
Also, from what i have understand there must be a place where you set up how many articles you want to display, but i wasn’t able to find it by myself.
Again, i think that Sven simply did an astonishing job with this plugin and with the other ones he released, i ‘d really like to know how to get it to work now.
I AM COMPLETELY STUCK.
Any support on this would be highly appreciated.
Sven said November 28th, 2007 at 07:46 PM ¶
Steph, y0rtz,
my impression is that you guys probably have a too old version of Mephisto installed. Mephisto really should ship with the withpaginate plugin itself. I have no idea if you by any means could use the plugin somehow with a version of Mephisto that doesn’t come with withpaginate.
if you have any urgent questions on this you can try to catch me in #mephisto (irc.freenode.net), too.
y0rtz said November 29th, 2007 at 12:43 AM ¶
Ehy Sven i tryed to see if i could find you in #mephisto with no luck:( Anyway, I can tell that i am running mephisto 0.7.2 stable flawlessly since i wanted to install the contact form plugin. Actually i tryed to download two fresh mephisto 0.7.2 and 0.7.3 release from the official site for the wonderful blogging system. No luck, I have found that both of them lack of support for the paginate plugin, what am i doing wrong? And also, where can i download the mephisto release with the “withpaginate” plugin? Thanks in advance and forgive my lameness…
Sven said November 29th, 2007 at 09:32 AM ¶
Hey y0rtz,
well I’m sticking around there the whole day long :) Are you from Australia or something?
So, no, have a look here: http://www.artweb-design.de/projects/mephisto-plugin-paged-article-lists … there are some Rails and Mephisto versions listed that are known to work. Actually I think that Rails 2.0 RC1 should work, too, with a fairly recent Mephisto version.
But you have to live on “edge”. Look at the Mephisto wiki for more info: http://mephisto.stikipad.com/help/show/Installing+Mephisto … the releases you mention are actually quite old. Unfortunatly there hasn’t been a release for more than a year now.
I hope that helps! If you can’t install Mephisto edge than I’m sorry that you probably won’t be able to use my pagination plugin, too … without some serious hacking, that is.
Xavier Shay said December 29th, 2007 at 01:00 AM ¶
http://svn.artweb-design.de/stuff/mephisto/mephistopagedarticlelist/lib/pagedarticle_list/
When I look there and also when I check out (r305), I don’t see will_paginate.rb. This concerns me … there is no code otherwise to implement to_liquid.
I looked at the svn log and it seems it should be there, so now I am really confused.
Sven said December 29th, 2007 at 11:15 AM ¶
Hi Xavier,
yes, it should be there.
You have to install it separately. Please refer to the plugin’s project page … I’ve separated the will_paginate_liquidized plugin for several reasons.
Eric Davis said January 3rd, 2008 at 09:41 AM ¶
I installed this plugin to my Mephisto install and was also getting some Liquid errors. After trying different Mephisto and Rails versions I found they all had the errors. Turns out the issue was with my liquid templates and a liquid partial.
Working on Mephisto r3036 and Rails r8129, http://theadmin.org
Hank said June 22nd, 2008 at 01:15 AM ¶
I’m getting the dreaded WillPaginate::Collection NameError like Steph was having above. Any thoughts on how to fix this?
kenderson said October 9th, 2008 at 04:24 AM ¶
Sven, I ran the install you suggested above, and am getting the following errors. Any suggestions? I am running Mephisto 0.8 and rails 2.0.2.
** Starting Rails with development environment… Exiting /Library/Ruby/Gems/1.8/gems/builder-2.1.2/lib/blankslate.rb:106:in
blankslate_original_append_features': cyclic include detected (ArgumentError) from /Library/Ruby/Gems/1.8/gems/builder-2.1.2/lib/blankslate.rb:106:inappend_features’ from /Rails/Ashleyandken/ak/trunk/vendor/plugins/willpaginateliquidized/trunk/lib/willpaginate/liquidized/viewhelpers.rb:3:ininclude' from /Rails/Ashleyandken/ak/trunk/vendor/plugins/will_paginate_liquidized/trunk/lib/will_paginate/liquidized/view_helpers.rb:3 from /Rails/Ashleyandken/ak/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:203:inloadwithoutnewconstantmarking’ from /Rails/Ashleyandken/ak/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:203:inload_file' from /Rails/Ashleyandken/ak/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:342:innewconstantsin’ from /Rails/Ashleyandken/ak/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:202:inload_file' from /Rails/Ashleyandken/ak/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:94:inrequire_or_load’ … 40 levels… from /Rails/Ashleyandken/ak/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:496:inrequire' from /Rails/Ashleyandken/ak/trunk/vendor/rails/railties/lib/commands/server.rb:39 from ./script/server:3:inrequire’ from ./script/server:3Steven Bakker said November 16th, 2008 at 05:52 PM ¶
@kenderson: I was pulling my hairs out on that error as well, and tried various versions of Mephisto to make it work, until I figured out the following: the installation of “willpaginateliquidized” pulls in the whole of the SVN repository, i.e. not only the trunk:
Gives me:
It seems the rails initialisation causes all of these instances to be included, resulting in cyclic includes.
You will have to keep only one of r413, r436, trunk. I did this by moving the whole of “willpaginateliquidized” out of the plugins directory and copying back one of the sub-directories to the plugins/willpaginateliquidized directory. For me, “trunk” didn’t work, neither did “r436”, but “r413” works!
Hope this helps.
Steven
Satish Chauhan said January 2nd, 2009 at 06:43 AM ¶
I have installed this plugin and its working fine for me, but I am have some issue when passing extra parameters in params, not getting other params parameter with the links (getting only page )
eg.
what I am getting : http://www.localhost:3000/products?page=2
expected: http://www.localhost:3000/products?page=2&perpage=10&sortby=name
Any support on this would be highly appreciated.
Thanks
Satish Chauhan said January 2nd, 2009 at 06:43 AM ¶
I have installed this plugin and its working fine for me, but I have some issue/problem when passing extra parameters in params, not getting other params parameter with the links (getting only page )
eg.
what I am getting : http://www.localhost:3000/products?page=2
expected: http://www.localhost:3000/products?page=2&perpage=10&sortby=name
Any support on this would be highly appreciated.
Thanks
jack said January 23rd, 2011 at 11:15 AM ¶
Do you know when Globalize will be ready for rails 2.0? cheap vps
QQQ said February 7th, 2011 at 06:34 PM ¶
Finally we kissed and the passion scale went sky high and I knew I was onto a good thing - sex was a certainty free porn videos. She never hesitated when I began to fondle her breasts and she willingly exposed them for me mobile porn. They were firm and I suspected a breast enhancement but said nothing - they still felt good and I was enjoying them and gradually working my way further south free porn tube. She was a step ahead of me and before I could completely undress her she moved on me atk hairy and I was suddenly having my pants pulled down and I was enjoying one of he best cock sucking hairy pussy experiences I had ever had. ABB728019394
Ming2 said February 24th, 2011 at 07:56 AM ¶
I didn’t call my agitation actual well. After searching at things afresh I should accept said that your pagination works but it doesn’t plan for sections. pass4sure 642-583 I brainstorm there’s a appealing simple fix about in area you’re architecture the links but I’m not abundant of a coder to amount it out. pass4sure 70-236 I am paginating through altered blog sections, pass4sure 70-299 it works on mephisto 0.8.2 pass4sure 70-350 I couldn’t acquisition any added quick and admired band-aid to the path issue.
lucie said March 14th, 2011 at 10:06 AM ¶
Thanks for the updated plugin, it was being discussed on this tech student site. They were saying it works great.
chat said March 31st, 2011 at 06:58 PM ¶
Here is a fix for the plugin:
The following cleaned up the issue:
Dependencies.loadoncepaths -= Dependencies.loadoncepaths.select{|path| \ path =~ %r(^#{File.dirname(FILE)}) }
Okey oyunu said May 12th, 2011 at 03:50 PM ¶
Tüm dünya artik okey oyunu oynuyor. Yillardir bir çok oyun programi olmasina ragmen, içlerinden en güzeli olarak nitelendirebilecegimiz tek bir site göze çarpmaktadir. Diger tüm okey oyunu programlarinin aksine ücretsiz olmasi ve 3 boyutlu olarak hizmet vermesi mükemmel bir gelismedir. Sizlerde www.okey-oyunu.com adresinden bu essiz okey oyununu indirebilirsiniz. Kullanimi çok basit ve Türkçe dil seçenegi ile kolaylikla oyuna baslayabilirsiniz. Ister kendi ülkenizden, isterseniz dünyanin tüm farkli bölgelerinden dilediginiz oyun odalarini seçerek, oyuna hemen baslayabilirsiniz. Okey oyunu oynamak için artik arkadas bile aramaniza gerek kalmadan, bilgisayarinizdan 100 binlerce üye ile online olarak okey oyununu oynamanin zevkine varabilirsiniz.
porno said May 22nd, 2011 at 01:30 PM ¶
I do agree with all of the ideas you have presented in your post. They’re really convincing and will definitely work. Still, the posts are too short for newbies. Could you please extend them a bit from next time? Thanks for the post.