示例#1
0
    def index_ajax(self):
        """Display the OLD Application home page.  This page is generated from
        the entry with name='home' of the table page_table of the model.  This
        page can be edited by administrators.

        """

        response.headers['Content-Type'] = 'application/json'
        result = {}

        # Get the number of Forms in the db
        result['formCount'] = str(h.getFormCount())

        # Get the homepage from the model
        homepage_q = meta.Session.query(model.Page).filter(
            model.Page.name==u'home')
        homepage = homepage_q.first()

        try:
            result['headerText'] = homepage.heading
            result['bodyContent'] = homepage.content
        except AttributeError:
            result['heading'] = u'There is no heading'
            result['content'] = u'There is no content for this page'

        # Perform a series of transformations on the page body content:
        #  1. convert reStructuredText to HTML, 2. link to OLD entities,
        #  3. embed Files and 4. Forms (LAST 3 SHOULD BE DONE CLIENT-SIDE)
        # Convert OLD Markup references to links/representations
        result['bodyContent'] = embedForms(
                                embedFiles(
                                linkToOLDEntitites(
                                h.rst2html(result['bodyContent']))))

        return json.dumps(result)
示例#2
0
    def index(self):
        """Display the OLD Application home page.  This page is generated from
        the entry with name='home' of the table page_table of the model.  This
        page can be edited by administrators.
        
        """
        
        # Get the number of Forms in the db
        c.formCount = str(h.getFormCount())
        
        # Get the homepage from the model
        homepage_q = meta.Session.query(model.Page).filter(
            model.Page.name==u'home')
        homepage = homepage_q.first()

        try:
            c.heading = homepage.heading
            c.content = homepage.content
        except AttributeError:
            c.heading = u'There is no heading'
            c.content = u'There is no content for this page'

        # Convert reStructuredText to HTML
        c.content = h.rst2html(c.content)
        
        # Convert OLD Markup references to links/representations
        c.content = linkToOLDEntitites(c.content)
        c.content = embedFiles(c.content)
        c.content = embedForms(c.content)
        
        return render('/derived/home/index.html')