Digg-Style Pagination in Java
public ArrayList getPagingLinks(){
ArrayList pages = new ArrayList();
if (pageCount < (7 + (adjacents * 2))){
for(int i=1; i<=pageCount; i++){
pages.add(i);
}
} else if(currentPage < ((adjacents * 3) + 1)){
for(int i=1; i<=(4 + (adjacents * 2)); i++){
pages.add(i);
}
pages.add("e");
pages.add(pageCount);
} else if(((pageCount - (adjacents * 2)) > currentPage) && (currentPage > (adjacents * 2))){
pages.add(1);
pages.add("e");
for(int i=currentPage -adjacents; i<=currentPage +adjacents; i++){
pages.add(i);
}
pages.add("e");
pages.add(pageCount);
} else{
pages.add(1);
pages.add("e");
for(int i=pageCount - (adjacents *3); i<=pageCount; i++){
pages.add(i);
}
}
return pages;
}
Basically, it creates a list of links to pages determined by the displayCount. If the page number equals the current page or the page number is greater than the page count, then no link will be added, only the page number.
Digg is my guilty pleasure...
Dear Digg,
I just don’t know how to quit you. Your front page with its ultimate tutorial lists, DIY hacks, news of new software releases, links to photos of scantily-clad women & oh God, don’t get me started on diggnation. Digg, you make me feel… inadequate. There’s always something new to tweak, new software to try, links to bookmark, news stories to, err…’research’. I can’t keep up.
And who’s fault is it that I feel inadequate? Well, I certainly can’t be the one to blame; you are everywhere! Even after removing all digg artifacts from my browser, I cannot escape the ‘digg this’ buttons & the ‘top-on-digg’ widgets slopped on various blogs (I think there was one on this blog at one time). You are in my internetz, destroying my blankspaces & thus, my self-esteem (not that that is terribly hard).
I want my simple, pre-digg life back; a life where I did important things, like save kittens & write “bad” poetry.
Fortunately, my interest in mouseHole has given me reason to spend less time at digg and more time at code.whytheluckystiff.net/mouseHole/ (Google says I’ve made 6 visits since the middle of this month! & that excludes all of the internet stalking I’ve been doing at the library). Now, I know what your’e thinking… “Just write a nice little mouseHole script to removes all of the digg paraphernalia from around the web.” And writing such a script would be a smart thing for me to do; my time away from digg would result in more time away from digg. But alas, I can’t seem to quit you. In fact, the mouseHole script that I ended up writing [1] uses your new API to display the number of diggs for the page I am currently viewing, along with (what else) a link to that page on digg.

And you know, the thing is that I suck at writing Ruby. Hell, I don’t even know if I’m a programmer yet. I have lots to learn and do with Ruby; I don’t have time for you & your front page and especially not for your comments or video podcasts. Maybe you could meet me half way and make yourself a paid-members only site? No? Then, I am hopelessly yours. Just promise me that you won’t take all of my time and that if you ever leave me for good, that you will return that little piece of my heart that I have given to you.
Lovingly, but irritatedly,
JessiRae
[1] Using this Ruby Digg Wrapper, I added to the browserbar.rb mouseHole script that I created earlier. The browserbar script places a list of links at the top of every page; the list forms a bar, similar to the plugins and quick links firefox makes available. Yeah, sure you are making all of your web surfing known to digg, but that just makes the guilt stronger. To use the digg “plugin”, place the digg.rb wrapper in your {mouseHole_root}/lib/mouseHole directory.
