예제 #1
0
파일: wi.py 프로젝트: jansaris/AminoPVR
 def _serveDBContent( self, filename, contentType = None ):
     conn = DBConnection()
     try:
         result = conn.execute( "SELECT content FROM glashart_pages WHERE page=?", [filename] )
         if result:
             row = result[0]
             if contentType:
                 cherrypy.response.headers["Content-Type"] = contentType
             return row["content"]
         else:
             raise cherrypy.HTTPError( 404 )
     except:
         raise cherrypy.HTTPError( 500 )
예제 #2
0
파일: wi.py 프로젝트: jansaris/AminoPVR
 def _serveDBContent(self, filename, contentType=None):
     conn = DBConnection()
     try:
         result = conn.execute(
             "SELECT content FROM glashart_pages WHERE page=?", [filename])
         if result:
             row = result[0]
             if contentType:
                 cherrypy.response.headers["Content-Type"] = contentType
             return row["content"]
         else:
             raise cherrypy.HTTPError(404)
     except:
         raise cherrypy.HTTPError(500)
예제 #3
0
    def _translateContent(self):
        indexContent, title, codeJsPath, styleCssPath = self._parseIndexPage()
        if title and indexContent:
            codeJsContent, symbolNames = self._parseCodeJs(codeJsPath)
            if codeJsContent:
                indexContent = self._modifyIndexPage(indexContent)
                codeJsContent = self._modifyCodeJs(codeJsContent, symbolNames)
                styleCssContent = self._getStyleCss(styleCssPath)
                apiJsContent = self._modifyApiJs(symbolNames)
                if indexContent and codeJsContent and styleCssContent and apiJsContent:
                    self._logger.warning(
                        "_translateContent: content translated: title=%s" %
                        (title))
                    conn = DBConnection()

                    if conn:
                        row = conn.execute(
                            "SELECT * FROM glashart_pages WHERE page=?",
                            ("index.xhtml", ))
                        if row:
                            conn.execute(
                                "UPDATE glashart_pages SET content=? WHERE page=?",
                                (indexContent, "index.xhtml"))
                        else:
                            conn.insert(
                                "INSERT INTO glashart_pages (page, content) VALUES (?, ?)",
                                ("index.xhtml", indexContent))

                        row = conn.execute(
                            "SELECT * FROM glashart_pages WHERE page=?",
                            ("code.js", ))
                        if row:
                            conn.execute(
                                "UPDATE glashart_pages SET content=? WHERE page=?",
                                (codeJsContent, "code.js"))
                        else:
                            conn.insert(
                                "INSERT INTO glashart_pages (page, content) VALUES (?, ?)",
                                ("code.js", codeJsContent))

                        row = conn.execute(
                            "SELECT * FROM glashart_pages WHERE page=?",
                            ("style.css", ))
                        if row:
                            conn.execute(
                                "UPDATE glashart_pages SET content=? WHERE page=?",
                                (styleCssContent, "style.css"))
                        else:
                            conn.insert(
                                "INSERT INTO glashart_pages (page, content) VALUES (?, ?)",
                                ("style.css", styleCssContent))

                        row = conn.execute(
                            "SELECT * FROM glashart_pages WHERE page=?",
                            ("api.js", ))
                        if row:
                            conn.execute(
                                "UPDATE glashart_pages SET content=? WHERE page=?",
                                (apiJsContent, "api.js"))
                        else:
                            conn.insert(
                                "INSERT INTO glashart_pages (page, content) VALUES (?, ?)",
                                ("api.js", apiJsContent))

                if symbolNames:
                    conn = DBConnection()
                    if conn:
                        PageSymbol.addAllDictToDb(conn, symbolNames)
예제 #4
0
    def _translateContent( self ):
        indexContent, title, codeJsPath, styleCssPath = self._parseIndexPage()
        if title and indexContent:
            codeJsContent, symbolNames = self._parseCodeJs( codeJsPath )
            if codeJsContent:
                indexContent    = self._modifyIndexPage( indexContent )
                codeJsContent   = self._modifyCodeJs( codeJsContent, symbolNames )
                styleCssContent = self._getStyleCss( styleCssPath )
                apiJsContent    = self._modifyApiJs( symbolNames )
                if indexContent and codeJsContent and styleCssContent and apiJsContent:
                    self._logger.warning( "_translateContent: content translated: title=%s" % ( title ) )
                    conn = DBConnection()

                    if conn:
                        row = conn.execute( "SELECT * FROM glashart_pages WHERE page=?", ( "index.xhtml", ) )
                        if row:
                            conn.execute( "UPDATE glashart_pages SET content=? WHERE page=?", ( indexContent, "index.xhtml" ) )
                        else:
                            conn.insert( "INSERT INTO glashart_pages (page, content) VALUES (?, ?)", ( "index.xhtml", indexContent ) )

                        row = conn.execute( "SELECT * FROM glashart_pages WHERE page=?", ( "code.js", ) )
                        if row:
                            conn.execute( "UPDATE glashart_pages SET content=? WHERE page=?", ( codeJsContent, "code.js" ) )
                        else:
                            conn.insert( "INSERT INTO glashart_pages (page, content) VALUES (?, ?)", ( "code.js", codeJsContent ) )

                        row = conn.execute( "SELECT * FROM glashart_pages WHERE page=?", ( "style.css", ) )
                        if row:
                            conn.execute( "UPDATE glashart_pages SET content=? WHERE page=?", ( styleCssContent, "style.css" ) )
                        else:
                            conn.insert( "INSERT INTO glashart_pages (page, content) VALUES (?, ?)", ( "style.css", styleCssContent ) )

                        row = conn.execute( "SELECT * FROM glashart_pages WHERE page=?", ( "api.js", ) )
                        if row:
                            conn.execute( "UPDATE glashart_pages SET content=? WHERE page=?", ( apiJsContent, "api.js" ) )
                        else:
                            conn.insert( "INSERT INTO glashart_pages (page, content) VALUES (?, ?)", ( "api.js", apiJsContent ) )

                if symbolNames:
                    conn = DBConnection()
                    if conn:
                        PageSymbol.addAllDictToDb( conn, symbolNames )