Skip to content

Commit

Permalink
*) added previous/next links to blog (in case blog has more entries t…
Browse files Browse the repository at this point in the history
…han get displayed on one page)

The blog still has a major problem: entries are displayed in random(?) order if there are several entries in the blog

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4339 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
low012 committed Jan 17, 2008
1 parent a0f7f2f commit 739f35d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 23 deletions.
32 changes: 23 additions & 9 deletions htroot/Blog.html
Expand Up @@ -6,14 +6,14 @@
<link rel="alternate" type="application/rss+xml" title="RSS" href="Blog.rss" />
</head>
<body id="Blog">
#(display)#
#%env/templates/simpleheader.template%#
#%env/templates/submenuPublication.template%#
::
#%env/templates/header.template%#
#%env/templates/submenuPublication.template%#
::
#%env/templates/embeddedheader.template%#
#(display)#
#%env/templates/simpleheader.template%#
#%env/templates/submenuPublication.template%#
::
#%env/templates/header.template%#
#%env/templates/submenuPublication.template%#
::
#%env/templates/embeddedheader.template%#
#(/display)#
#(mode)#
<!-- 0: viewing -->
Expand All @@ -28,7 +28,21 @@ <h2 class="PostSubject"><a href="Blog.html?page=#[pageid]#">#[subject]#</a></h2>
</p>
</div>
#{/entries}#
#(moreentries)#::<p class="Navigation"><a href="Blog.html?start=#[start]#&amp;num=#[num]#">show more entries...</a></p>#(/moreentries)#
<div class="BlogCommentPrevNext">
<p>
#(preventries)#
&lt;&lt; previous entries
::
<a href="Blog.html?start=#[start]#&amp;num=#[num]#">&lt;&lt; previous entries</a>
#(/preventries)#
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
#(moreentries)#
next entries &gt;&gt;
::
<a href="Blog.html?start=#[start]#&amp;num=#[num]#">next entries &gt;&gt;</a>
#(/moreentries)#
</p>
</div>
<p class="Navigation">
#(admin)#<a href="Blog.html?login=true">Login</a> - ::<a href="Blog.html?edit=true">new entry</a> - <a href="Blog.html?import=xml">import XML-File</a> - <a href="Blog.xml?xml=1">export as XML</a> - #(/admin)#<a href="Blog.html">Blog-Home</a>
</p>
Expand Down
18 changes: 15 additions & 3 deletions htroot/Blog.java
Expand Up @@ -99,11 +99,11 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
if (post == null) {
prop.putHTML("peername", yacyCore.seedDB.mySeed().getName());
prop.put("address", address);
return putBlogDefault(prop, switchboard, address, 0, 20, hasRights, xml);
return putBlogDefault(prop, switchboard, address, 0, 10, hasRights, xml);
}

final int start = post.getInt("start",0); //indicates from where entries should be shown
final int num = post.getInt("num",20); //indicates how many entries should be shown
final int num = post.getInt("num",10); //indicates how many entries should be shown

if(!hasRights){
final userDB.Entry userentry = switchboard.userDB.proxyAuth((String)header.get("Authorization", "xxxxxx"));
Expand Down Expand Up @@ -294,9 +294,12 @@ private static serverObjects putBlogDefault(
try {
final Iterator i = switchboard.blogDB.keys(false);
String pageid;
int count = 0; //counts how many entries are shown to the user
int count = 0; //counts how many entries are shown to the user
if(xml) num = 0;
final int nextstart = start+num; //indicates the starting offset for next results
int prevstart = start-num; //indicates the starting offset for previous results
boolean prev = false; //indicates if there were previous comments to the ones that are dispalyed
if (start > 0) prev = true;
while(i.hasNext() && (num == 0 || num > count)) {
pageid = (String) i.next();
if(0 < start--) continue;
Expand All @@ -317,6 +320,15 @@ private static serverObjects putBlogDefault(
} else {
prop.put("moreentries", "0");
}

if(prev) {
prop.put("mode_preventries", "1");
if (prevstart < 0) prevstart = 0;
prop.put("mode_preventries_start", prevstart);
prop.put("mode_preventries_num", num);
} else prop.put("mode_preventries", "0");


} catch (IOException e) { serverLog.logSevere("BLOG", "Error reading blog-DB", e); }
return prop;
}
Expand Down
24 changes: 13 additions & 11 deletions htroot/BlogComments.html
Expand Up @@ -30,17 +30,19 @@ <h2 class="PostSubject">#[subject]#</h2>
</div>
#{/entries}#
<div class="BlogCommentPrevNext">
#(preventries)#
&lt;&lt; previous entries
::
<a href="BlogComments.html?page=#[pageid]#&amp;start=#[start]#&amp;num=#[num]#">&lt;&lt; previous entries</a>
#(/preventries)#
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
#(moreentries)#
next entries &gt;&gt;
::
<a href="BlogComments.html?page=#[pageid]#&amp;start=#[start]#&amp;num=#[num]#">next entries &gt;&gt;</a>
#(/moreentries)#
<p>
#(preventries)#
&lt;&lt; previous entries
::
<a href="BlogComments.html?page=#[pageid]#&amp;start=#[start]#&amp;num=#[num]#">&lt;&lt; previous entries</a>
#(/preventries)#
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
#(moreentries)#
next entries &gt;&gt;
::
<a href="BlogComments.html?page=#[pageid]#&amp;start=#[start]#&amp;num=#[num]#">next entries &gt;&gt;</a>
#(/moreentries)#
</p>
</div>
#(allow)#
<fieldset>
Expand Down

0 comments on commit 739f35d

Please sign in to comment.