コード例 #1
0
ファイル: Site.py プロジェクト: 15831944/IslandLinks
    def setTitle(self, data):
        data = json.read(data)

        #Update Page with new title
        Model.Pages.setPageTitle(data['page_id'], data['new_val'])

        AmiCache.expireCurrentPage()
        return "ok"
コード例 #2
0
ファイル: Site.py プロジェクト: 15831944/IslandLinks
    def setLogin(self, username, password):
        login_ok = UserModel.Users.checkLogin(username, password)
        if login_ok:
            session = amiweb.session()
            session['logged_in'] = True
            session['username'] = username
            self.setViewEditMode("on")

            AmiCache.expireEditPages()
            page = Model.Pages.getPageById(getCurrentPage())
            ns = {'template': self.template, 'full_link': page.getFullLink()}
            return render("skeletonz/view/whole_sites/login_ok.tmpl", ns)
コード例 #3
0
ファイル: Site.py プロジェクト: 15831944/IslandLinks
    def setLogout(self, id):
        session = amiweb.session()
        try:
            id = int(id)
        except:
            id = getCurrentPage()
        session['logged_in'] = False
        session['username'] = None
        AmiCache.expireEditPages()
        page = Model.Pages.getPageById(id)

        url = "%s/%s" % (BASE_URL, page.getFullLink())
        raise amiweb.HTTPFound(url)
コード例 #4
0
ファイル: Site.py プロジェクト: 15831944/IslandLinks
    def setContent(self, page_id, new_val=""):
        new_val = unicode(new_val, 'utf8')
        new_val = new_val.replace("\r\n", "\n")

        #Update Page with new title
        Model.Pages.setPageContent(page_id, new_val)

        AmiCache.expireCache(page_id)
        if Users.getViewEditMode() == 'on':
            result = Model.Pages.getPageById(page_id).getContentEdit()
        else:
            result = Model.Pages.getPageById(page_id).getContent()
        return result
コード例 #5
0
ファイル: Site.py プロジェクト: 15831944/IslandLinks
    def deletePage(self, id):
        #TODO: Refactor this (and other methods) to plugins/wikipages
        page = Model.Pages.getPageById(id)
        url_mapper.expirePagePath(page.getFullLink())

        current_page = Model.Pages.getPageById(getCurrentPage())
        page_name = Model.Pages.getPageById(id).name
        Model.Pages.deletePageById(id)

        AmiCache.expireAllPages()

        #Find the right plugin args
        args = getFormatManager().getPluginArguments('page', page_name)
        html = wiki_filter.wikiWords(args, True, current_page)
        return html
コード例 #6
0
ファイル: Site.py プロジェクト: 15831944/IslandLinks
    def servePage(self, page_id, current_info):
        print "[Site] SiteEdit servePage: servingPage<br>"
        edit_mode = current_info['edit_mode']
        if AmiCache.isCacheUp2Date(page_id, is_edit=edit_mode):
            if current_info['is_CMS_page']:
                amiweb.session()["current_page_id"] = page_id
            content = AmiCache.getValue(page_id, is_edit=edit_mode)
        else:
            content = renderView(current_info, "site_structure")

            AmiCache.updateCache(page_id, content, is_edit=edit_mode)
        page = Model.Pages.getPageById(page_id)

        #Append dynamic sections to this
        content = sections.fillSections(current_info, content, page)
        return content
コード例 #7
0
ファイル: Site.py プロジェクト: 15831944/IslandLinks
    def servePage(self, page_id, current_info):
        #print "[Site] Site servePage:<br>"
        if page_id and AmiCache.isCacheUp2Date(page_id):
            #print "[Site] Site servePage: pulling page from session<br>"
            if current_info['is_CMS_page']:
                amiweb.session()["current_page_id"] = page_id
            content = AmiCache.getValue(page_id)
        else:
            #print "[Site] Site servePage: loading & rendering page and putting in session<br>"
            content = renderView(current_info, "site_structure")
            page = Model.Pages.getPageById(page_id)

            #Append sections to this
            content = sections.fillSections(current_info, content, page)

            AmiCache.updateCache(page_id, content)
        return content
コード例 #8
0
ファイル: Site.py プロジェクト: 15831944/IslandLinks
    def setParent(self, page_id, parent_id):
        page_id = int(page_id)
        parent_id = int(parent_id)

        if parent_id == 0:
            parent_id = None

        current_page = Model.Pages.getPageById(page_id)

        if parent_id:
            parent_page = Model.Pages.getPageById(parent_id)

            #Make sure the current page isn't a parent for that parent
            parents = parent_page.getParentList()
            for pa in parents:
                if pa.id == page_id:
                    raise amiweb.AppError(
                        "You can't changes a parents child to be a parent of the parent... I.e. recursion problem!"
                    )

        old_parent = current_page.getParent()
        Model.Pages.setParent(page_id, parent_id)

        #Expire havoc
        AmiCache.expireCache(page_id)

        if old_parent:
            AmiCache.expireCache(old_parent.id)
        if parent_id:
            AmiCache.expireCache(parent_id)
        return "ok"
コード例 #9
0
    def changeTemplate(self, id):
        try:
            exec "from templates.%s import template as m" % json.read(id)
            old_template_name = getConfig().CURRENT_TEMPLATE.NAME
            getConfig().CURRENT_TEMPLATE = m

            AmiCache.expireAllPages()

            rc = server.getRootController()

            site_template = m.SiteTemplate()
            site_edit_template = SiteEditTemplate(m.SiteTemplate)

            site_template.markChildren()

            rc.root_obj.template = site_template
            rc.root_obj.siteedit.template = site_edit_template
            initTemplate(site_template, 'addToSiteTemplate')
            initTemplate(site_edit_template, 'addToSiteEditTemplate')

            server.setTemplateStaticPaths(rc, old_template_name)

        except Exception, inst:
            print "'%s' is not a valid template" % inst
コード例 #10
0
ファイル: Site.py プロジェクト: 15831944/IslandLinks
    def setPageHidden(self, page_id, value):
        Users.checkCurrentPagePermissions()
        Model.Pages.setPageHidden(page_id, value)

        #Expire the parent also
        page_obj = Model.Pages.getPageById(page_id)
        if page_obj.parent_id:
            AmiCache.expireCache(page_obj.parent_id)

        #Expire every page in the menu
        for m_item in Model.MenuItems.getItemsByMenuId(1):
            AmiCache.expireCache(m_item.page_id)

        AmiCache.expireCurrentPage()
        return value
コード例 #11
0
ファイル: Site.py プロジェクト: 15831944/IslandLinks
 def pageCreate(self, parent_id, name):
     new_page = Model.Pages.insertPageFromWiki(parent_id, name)
     AmiCache.expireCache(parent_id)
     raise amiweb.HTTPFound("%s/siteedit/?page_id=%i" %
                            (BASE_URL, new_page.id))
コード例 #12
0
 def restoreSnapshot(self, filename):
     s = backup.SnapShot()
     s.restoreZip(filename)
     AmiCache.expireAllPages()
     return "ok"
コード例 #13
0
 def index(self):
     ns = {
         'template': self.template,
         'cache_up_to_date': AmiCache.areAllPagesUp2Date()
     }
     return render("skeletonz/view/admin/ServerManager_index.tmpl", ns)
コード例 #14
0
 def restart_cache(self):
     url_mapper.expirePageMemo()
     AmiCache.expireAllPages()
     AmiCache.cacheAllPages()
     return "ok"
コード例 #15
0
ファイル: Site.py プロジェクト: 15831944/IslandLinks
 def pageLinkUpdate(self, page_link_id, new_page_id, current_pid):
     Model.PageLinks.set(page_link_id, new_page_id)
     AmiCache.expireCache(current_pid)
     page = Model.Pages.getPageById(new_page_id)
     return "%s/siteedit/%s" % (BASE_URL, page.getFullLink())
コード例 #16
0
 def deletePage(self, id):
     Model.Pages.deletePageById(id)
     AmiCache.expireAllPages()
     return "ok"
コード例 #17
0
ファイル: Site.py プロジェクト: 15831944/IslandLinks
 def setViewEditMode(self, value):
     amiweb.session()['view_edit_mode'] = value
     AmiCache.expireEditPages()
コード例 #18
0
ファイル: Site.py プロジェクト: 15831944/IslandLinks
 def revert(self, page_id, rev):
     obj_rev = Model.PageLogs.getLogByRev(page_id, rev)
     Model.Pages.setPageContent(page_id, obj_rev.text)
     AmiCache.expireCache(page_id)
     return 'ok'
コード例 #19
0
 def expirePages(self, id):
     for page in upload_model.Files.getAllPagesWhereFileIsUsed(id):
         AmiCache.expireCache(page.id)