Commit 87d8eb62 authored by jan.koester's avatar jan.koester
Browse files

mobile template support

parent 43ea45df
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -54,15 +54,17 @@ namespace blogi {
            sql << "CREATE TABLE IF NOT EXISTS templates ("
                << "id integer PRIMARY KEY " << Args->database[0]->autoincrement() << ","
                << "layer varchar(255),"
                << "html text"
                << "html text,"
                << "integer type"
                << ");";
            Args->database[0]->exec(&sql,res);
        };

        void Rendering(const int tid,libhttppp::HttpRequest *req,libhtmlpp::HtmlElement* curpage){
        void Rendering(const int tid,libhttppp::HttpRequest *req,libhtmlpp::HtmlElement* curpage,int type){

            blogi::SQL sql;
            blogi::DBResult res;
            sql << "select id,layer,html from templates";
            sql << "select id,layer,html,type from templates";

            std::string turl=req->getRequest();
            if(turl.rfind('?')>0){
@@ -75,12 +77,14 @@ namespace blogi {
            }

            for (int i = 0; i < n; i++) {
                if(atoi(res[i][3])==RenderingType::All || type==atoi(res[i][3])){
                    libhtmlpp::HtmlString buf;
                    buf << res[i][2];
                    libhtmlpp::HtmlElement *el=curpage->getElementbyID(res[i][1]);
                    if(el)
                        el->appendChild(buf.parse());
                }
            }

        }

+9 −2
Original line number Diff line number Diff line
@@ -162,7 +162,10 @@ void blogi::Blogi::loginPage(libhttppp::HttpRequest *curreq,const int tid){
            index.getElementbyID("main")->insertChild(condat.parse());

        for(blogi::Plugin::PluginData *curplg=BlogiPlg->getFirstPlugin(); curplg; curplg=curplg->getNextPlg()){
            curplg->getInstace()->Rendering(tid,curreq,&index);
            if(curreq->isMobile())
                curplg->getInstace()->Rendering(tid,curreq,&index,RenderingType::Mobile);
            else
                curplg->getInstace()->Rendering(tid,curreq,&index,RenderingType::Desktop);
        }

        PlgArgs->theme->printSite(tid,out,&index,curreq->getRequestURL(),false);
@@ -479,7 +482,11 @@ int main(int argc, char** argv){

    try{
#ifndef Windows
        signal(SIGPIPE, SIG_IGN);

        struct sigaction SignalAction = {0};
        /* Ignore broken pipes, which can happen when the remote side is not behaving well */
        SignalAction.sa_handler = SIG_IGN;
        sigaction (SIGPIPE, &SignalAction, nullptr);

        if(debug==0){
            if(getuid()!=0){
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ bool blogi::PluginApi::haveSettings(){
    return false;
}

void blogi::PluginApi::Rendering(const int tid,libhttppp::HttpRequest *req,libhtmlpp::HtmlElement *curpage){
void blogi::PluginApi::Rendering(const int tid,libhttppp::HttpRequest *req,libhtmlpp::HtmlElement *curpage,int type){
    return;
}

+3 −1
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@ namespace blogi {
        bool      debug;
    };

    enum RenderingType {All=0,Desktop=1,Mobile=2};

    class PluginApi {
    public:
        virtual ~PluginApi()=0;
@@ -67,7 +69,7 @@ namespace blogi {

        virtual void Settings(const int tid,libhttppp::HttpRequest *req,libhtmlpp::HtmlString &setdiv);

        virtual void Rendering(const int tid,libhttppp::HttpRequest *req,libhtmlpp::HtmlElement *curpage);
        virtual void Rendering(const int tid,libhttppp::HttpRequest *req,libhtmlpp::HtmlElement *curpage,int type=0);
    protected:
        PluginArgs *Args;
    };