예제 #1
0
    def gen_page(self, note=list(), num=0, public=True):
        import os
        import os.path

        page_file = "./" + self.gen_public_link(note[0])
        page_dir = os.path.dirname(page_file)

        if not os.path.exists(page_dir):
            os.makedirs(page_dir)

        output = open(page_file, "w")
        print(self.header_prefix(2, note[1].strip()), file=output)
        print(self.body_prefix(), file=output)
        print(self.body_menu(self.menus), file=output)
        if public:
            print(self.contain_prefix(self.page_tags[note[0]], "标签: ",
                                      util.gen_title(note[0])),
                  file=output)
        else:
            print(self.contain_prefix([self.nopublic_tag], "标签: ",
                                      util.gen_title(note[0])),
                  file=output)
        print(self.contain_page(note[0], num, public), file=output)  # auto gen
        print(self.gen_sidebar(), file=output)
        print(self.contain_suffix(), file=output)
        print(self.header_suffix(), file=output)
        output.close()
예제 #2
0
파일: parser.py 프로젝트: smashell/OrgNote
    def gen_page(self,note=list(),num=0,public=True):
        import os
        import os.path
        
        page_file = "./" + self.gen_public_link(note[0])
        page_dir = os.path.dirname(page_file)
        
        if not os.path.exists(page_dir):
            os.makedirs(page_dir)

        output = open(page_file,"w")
        print >> output,self.header_prefix(2,note[1].strip())
        print >> output,self.body_prefix()
        print >> output,self.body_menu(self.menus)
        if public:
            print >> output,self.contain_prefix(self.page_tags[note[0]],"标签: ",util.gen_title(note[0]))
        else:
            print >> output,self.contain_prefix(['nopublic'],"标签: ",util.gen_title(note[0]))
        print >> output,self.contain_page(note[0],num,public)              # auto gen
        print >> output,self.gen_sidebar()
        print >> output,self.contain_suffix()
        print >> output,self.header_suffix()
        output.close()
예제 #3
0
파일: parser.py 프로젝트: smashell/OrgNote
    def contain_notes(self,data=list(),num=0,lastone=0):
        # each note

        output = ""

        for item in data:
            output += """
            <h3 class="title">
            <a href="%s">%s</a>
            <span class="date">%s </span>
            </h3>
            """ % (self.gen_public_link(item[0],self.public_dir),item[1],self.gen_date(item[0]))


            if self.emacs_version[0] >= 24 and self.emacs_version[1] >= 4:
                output += """<div class="col-md-12">"""
            else:
                output += """            
                <div class="entry">
                <div class="row">
                <div class="col-md-12">
                """
                

        
            output += self.contain_note(item[0])

            sub_title = sub_title = "<h1 class=\"title\">%s</h1>" % util.gen_title(item[0])
            output = output.replace(sub_title,"")
            
            output += """
            </div> <!-- entry -->
            """
        

        if num == 0:
            prev_page = '<li class="prev disabled"><a><i class="fa fa-arrow-circle-o-left"></i>Newer</a></li>'
        elif num == 1:
            prev_page = '<li class="prev"><a href="%s" class=alignright prev"><i class="fa fa-arrow-circle-o-left"></i>Newer</a></li>' % (self.blogroot + "index.html")
        else:
            prev_page = '<li class="prev"><a href="%s" class=alignright prev"><i class="fa fa-arrow-circle-o-left"></i>Newer</a></li>' % (self.public_dir + "page"+str(num-1)+".html")

        if lastone == len(self.notes):
            next_page = '<li class="next disabled"><a><i class="fa fa-arrow-circle-o-right"></i>Older</a></li>'
        else:
            next_page = '<li class="next"><a href="%s" class="alignright next">Older<i class="fa fa-arrow-circle-o-right"></i></a></li>' % (self.public_dir + "page"+str(num+1)+".html")

        output += """
        <div>
        <center>
        <div class="pagination">
        <ul class="pagination">
        %s
        <li><a href="%sarchive.html" target="_blank"><i class="fa fa-archive"></i>Archive</a></li>
        %s
        </ul>
        </div>
        </center>
        </div>
        """ % (prev_page,self.public_dir,next_page)
        
        output += self.duosuo()
        
        output += """
        </div> <!-- mypage -->
        </div> <!-- col-md-9 -->
        """ 

        return output
예제 #4
0
    def contain_notes(self, data=list(), num=0, lastone=0):
        # each note

        output = ""

        for item in data:
            output += """
            <h3 class="title">
            <a href="%s">%s</a>
            <span class="date">%s </span>
            </h3>
            """ % (self.gen_public_link(
                item[0], self.public_dir), item[1], self.gen_date(item[0]))

            if self.emacs_version[0] >= 24 and self.emacs_version[1] >= 4:
                output += """<div class="col-md-12">"""
            else:
                output += """            
                <div class="entry">
                <div class="row">
                <div class="col-md-12">
                """

            output += self.contain_note(item[0])

            sub_title = sub_title = "<h1 class=\"title\">%s</h1>" % util.gen_title(
                item[0])
            output = output.replace(sub_title, "")

            if self.emacs_version[0] >= 24 and self.emacs_version[1] >= 4:
                output += """
                </div> <!-- col-md-12 -->
                """
            else:
                output += """
                </div> <!-- col-md-12 -->
                </div> <!-- row -->
                </div> <!-- entry -->
                """

        if num == 0:
            prev_page = '<li class="prev disabled"><a><i class="fa fa-arrow-circle-o-left"></i>Newer</a></li>'
        elif num == 1:
            prev_page = '<li class="prev"><a href="%s" class=alignright prev"><i class="fa fa-arrow-circle-o-left"></i>Newer</a></li>' % (
                self.blogroot + "index.html")
        else:
            prev_page = '<li class="prev"><a href="%s" class=alignright prev"><i class="fa fa-arrow-circle-o-left"></i>Newer</a></li>' % (
                self.public_dir + "page" + str(num - 1) + ".html")

        if lastone == len(self.notes):
            next_page = '<li class="next disabled"><a><i class="fa fa-arrow-circle-o-right"></i>Older</a></li>'
        else:
            next_page = '<li class="next"><a href="%s" class="alignright next">Older<i class="fa fa-arrow-circle-o-right"></i></a></li>' % (
                self.public_dir + "page" + str(num + 1) + ".html")

        output += """
        <div>
        <center>
        <div class="pagination">
        <ul class="pagination">
        %s
        <li><a href="%sarchive.html" target="_blank"><i class="fa fa-archive"></i>Archive</a></li>
        %s
        </ul>
        </div>
        </center>
        </div>
        """ % (prev_page, self.public_dir, next_page)

        output += self.duosuo()

        output += """
        </div> <!-- mypage -->
        </div> <!-- col-md-9 -->
        """

        return output