Commit faa8230d authored by jan.koester's avatar jan.koester
Browse files

blogi have now pager

parent df9fa794
Loading
Loading
Loading
Loading
+29 −5
Changes for plugins/content/content.cpp: 29 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *******************************************************************************/

#include<iostream>

#include <htmlpp/html.h>
#include <httppp/http.h>
#include <httppp/exception.h>
@@ -34,6 +36,8 @@
#include <conf.h>
#include <plugin.h>

#define SITELIMIT 10

namespace blogi {
    class Content : public PluginApi{
    public:
@@ -43,7 +47,7 @@ namespace blogi {
        ~Content(){
        };

        void contentIdxPage(netplus::con *curcon,libhttppp::HttpRequest *curreq,const char *tag){
        void contentIdxPage(netplus::con *curcon,libhttppp::HttpRequest *curreq,const char *tag,int start,int end){
            libhttppp::HTTPException excep;
            libhtmlpp::HtmlString condat;

@@ -63,11 +67,12 @@ namespace blogi {
                    sql = "select content.id,content.title,content.descrition,users.username,content.created from content ";
                    sql <<"LEFT JOIN users ON content.author=users.id LEFT JOIN tags_content ON tags_content.content_id=content.id where tags_content.tag_id='"
                    << res[0][0]
                    <<"' ORDER BY id DESC";
                    <<"' ORDER BY id DESC OFFSET " << start << " LIMIT " << end;
                    ncount=Args->database->exec(&sql,res);
                }
            } else {
                sql="select content.id,content.title,content.descrition,users.username,content.created from content LEFT JOIN users ON content.author=users.id ORDER BY id DESC";
                sql << " OFFSET " << start << " LIMIT " << end;
                ncount=Args->database->exec(&sql,res);
            }

@@ -98,7 +103,15 @@ namespace blogi {
                meta.append(" ");
            }

            condat << "</div>";
            condat << "<div id=\"pager\">";

            if((start - end) >= 0)
                condat << "<a href=\"" << curreq->getRequestURL() << "?start=" << (start- end) <<"\" > Zur&uuml;ck </a>";

            if((ncount -10) >= 0 )
                condat << "<a href=\"" << curreq->getRequestURL() << "?start=" << start+10 <<"\" > Weiter </a>";

            condat << " </div> </div>";

            sql="SELECT name,id FROM tags";

@@ -574,6 +587,8 @@ namespace blogi {

            std::string curl=req->getRequestURL();

            std::cerr << curl << std::endl;

            if(curl.find('?')>=0){
                curl=curl.substr(0,curl.find('?'));
            }
@@ -595,11 +610,20 @@ namespace blogi {
               resp.send(curcon,robot,strlen(robot));
               return true;
            }else{
                int startpos = 0;
                libhttppp::HttpForm start;
                start.parse(req);
                for (libhttppp::HttpForm::UrlcodedFormData* cururlform = start.getUrlcodedFormData(); cururlform;
                    cururlform = cururlform->nextUrlcodedFormData()){
                    if(strcmp(cururlform->getKey(),"start")==0)
                        startpos=atoi(cururlform->getValue());
                }
                std::cerr << startpos << std::endl;
                if (strcmp(curl.c_str(),Args->config->buildurl("content/tag",url,512))>0){
                    size_t len = strlen(Args->config->buildurl("content/tag/",url,512));
                    contentIdxPage(curcon,req,curl.substr(len,curl.length()-len).c_str());
                    contentIdxPage(curcon,req,curl.substr(len,curl.length()-len).c_str(),startpos,SITELIMIT);
                 }else{
                    contentIdxPage(curcon,req,nullptr);
                    contentIdxPage(curcon,req,nullptr,startpos,SITELIMIT);
                 }
            }
            return true;
+27 −0
Changes for src/settings.cpp: 27 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*******************************************************************************
 * Copyright (c) 2023, Jan Koester jan.koester@gmx.net
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 * Neither the name of the <organization> nor the
 *      names of its contributors may be used to endorse or promote products
 *      derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *******************************************************************************/

+26 −0
Changes for src/settings.h: 26 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*******************************************************************************
 * Copyright (c) 2023, Jan Koester jan.koester@gmx.net
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 * Neither the name of the <organization> nor the
 *      names of its contributors may be used to endorse or promote products
 *      derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *******************************************************************************/