示例#1
0
def wikiPageLink(args, edit_mode, current_page):
    """
    A href to a page in the system
    """
    ident = args['pagelink']
    section = args.get('section', None)
    result = getPageLinkHTML(ident, edit_mode, section, False)

    ns = {'normal_view': ident, 'edit_view': ''}

    if args.has_key('show_as'):
        show_as = args['show_as']
        if type(show_as) == types.DictType:
            if show_as['plugin_type'] == 'image':
                if edit_mode:
                    ns['normal_view'] = ''
                    ns['edit_view'] = getFormatManager().imageEditModeLink(
                        show_as, edit_mode)
                else:
                    ns['normal_view'] = getFormatManager().imageEditModeLink(
                        show_as, edit_mode)
                    ns['edit_view'] = ''
            else:
                print 'ERROR: Only images are supported in [pagelink=..., show_as=...]'
        else:
            ns['normal_view'] = show_as
    return render(result, ns, True)
示例#2
0
 def getEditHTML(self, type, ident, linkonly=0):
     if type == "skfile":
         args = getFormatManager().getPluginArguments('file', ident)
         return filter.wikiFiles(args, True, None)
     if type == "skimg":
         args = getFormatManager().getPluginArguments('image', ident)
         return filter.wikiImages(args, True, None)
     if type == "personnelimage":
         args = getFormatManager().getPluginArguments(
             'personnelimage', ident)
         return filter.personnelWikiImages(args, True, None)
示例#3
0
    def __init__(self):
        self.plugin_path = "skeletonz/plugins/upload"

        format_man = getFormatManager()
        format_man.registerSLPlugin('file', self.handleFiles)
        format_man.registerSLPlugin('image', self.handleImages)
        format_man.registerSLPlugin('personnelimage', self.handlePersonnelImages)
示例#4
0
    def viewArchive(self, path_info, formvars):
        blogid_year = path_info.split('/')[-1]
        sp = blogid_year.split('-')
        blog_id = sp[0]
        year = int(sp[1])

        kw = {}
        blog = BlogModel.getBlogById(blog_id)
        posts = blog.getPostsByYear(year)

        title = 'Post archive for year %s' % year
        ns = {
          'posts': posts,
          'amiformat': getFormatManager().noPluginFormat,
          'title': title,
          'GENERIC_POST_LINK': GENERIC_POST_LINK
        }
        kw['content'] = render('site_plugins/blog/view/viewPosts.tmpl', ns)

        kw['title'] = title
        kw['host_page'] = blog.host_page
        kw['id'] = "blogarchive_%s" % blogid_year
        kw['hidden'] = False
        kw['edit_mode'] = False
        kw['premission_type'] = 'Everyone'
        page_obj = Site.PageDeco(kw)
        return page_obj.servePage()
示例#5
0
    def __init__(self):
        self.mi_control = AMigrationControl("Blog",
            [model.Blog_Initial, model.Blog_MoveBlogOut,
             model.Blog_AddComments, model.Blog_RewriteLabels,
             model.Blog_MoveHostPage], plugin_configurator)

        format_man = getFormatManager()
        format_man.registerSLPlugin('blog', self.handleBlog)
        format_man.registerSLPlugin('blog_labels', self.handleBlogLabels)
        format_man.registerSLPlugin('blog_archive', self.handleBlogArchive)
        format_man.registerSLPlugin('blog_rsslink', self.handleBlogRssLink)
示例#6
0
    def cachePage(self, page):
        print "[amicache] Amicacher cachePage: hit the cache logic<br>"
        from skeletonz.Site import Site, renderView, getCurrentInfo

        tmpl = getConfig().CURRENT_TEMPLATE.SiteTemplate()
        tmpl.markChildren()

        site = Site(tmpl)

        getFormatManager().resetPagePlugins()

        current_info = getCurrentInfo(site.template, page.id, False)
        current_info['is_admin'] = False
        current_info['logged_in'] = False
        current_info['edit_mode'] = False
        current_info['edit_permission'] = None

        content = renderView(current_info, "site_structure")

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

        self.updateCache(page.id, content)
示例#7
0
def wikiFiles(args, edit_mode, current_page):
    up = Upload("file", args, model.Files.getFileByIdent, "skfile")

    btn_upload_new = html_helpers.createActionLink('Upload file', 'static_plugin/upload/file_add.png', "EC_Upload.showUploadWindowIdent('files', this.id, 'skfile')", tooltip_inner=True, id=args['file'])

    up.setUploadNew("""<span id="skfile_$ident_id" class="skfile"><span class="CMS_NotCreated">$normal_view</span> $edit_view \
  %s</span>""" % btn_upload_new)

    btn_edit = html_helpers.createActionLink('Upload new file', 'static_plugin/upload/file_edit.png', "EC_Upload.showUploadWindowId('files', '$obj.id', 'skfile')", tooltip_inner=True)
    btn_del = html_helpers.createActionLink('Delete file', 'static_plugin/upload/file_delete.png', "EC_Upload.deleteFile(this.parentNode, 'files', '$obj.id', 'skfile')", "CMS_link CMS_critical_link", tooltip_inner=True)

    up.setUploadEdit("""<span id="skfile_$ident_id" class="skfile"><a href="$obj.getFilename()">$normal_view</a> $edit_view \
  %s %s</span>""" % (btn_edit, btn_del))

    up.setView("""<a href="$obj.getFilename()">$normal_view</a>""")
    up.setViewNotCreated("""<span class="CMS_NotCreated">$normal_view</span> $edit_view""")

    normal_view = re.sub('\s*!\d+', '', args['file'])
    edit_view = ''

    if args.has_key('show_as'):
        show_as = args['show_as']
        if type(show_as) == types.DictType:
            if show_as['plugin_type'] == 'image':
                if edit_mode:
                    normal_view = ''
                    edit_view = getFormatManager().imageEditModeLink(show_as, edit_mode)
                else:
                    normal_view = getFormatManager().imageEditModeLink(show_as, edit_mode)
                    edit_view = ''
            else:
                print 'ERROR: Only images are supported in [page=..., show_as=...]'
        else:
            normal_view = show_as

    return up.appendFilter(edit_mode, normal_view=normal_view, edit_view=edit_view)
示例#8
0
    def viewLabelPosts(self, path_info, formvars):
        label_id = path_info.split('/')[-1]
        kw = {}
        label = BlogLabelModel.getById(label_id)
        posts = label.getPosts()
        blog = BlogModel.getBlogById(label.blog_id)

        title = '%s posts posted under label "%s"' % (len(posts), label.name)
        ns = {
          'posts': posts,
          'amiformat': getFormatManager().noPluginFormat,
          'title': title,
          'GENERIC_POST_LINK': GENERIC_POST_LINK
        }
        kw['content'] = render('site_plugins/blog/view/viewPosts.tmpl', ns)

        kw['title'] = title
        kw['host_page'] = blog.host_page
        kw['id'] = "bloglabel_%s" % label_id
        kw['hidden'] = False
        kw['edit_mode'] = False
        kw['premission_type'] = 'Everyone'
        page_obj = Site.PageDeco(kw)
        return page_obj.servePage()
示例#9
0
 def filterContent(text):
     return getFormatManager().htmlFormat(text, False, True, page_obj)
示例#10
0
 def updateComment(self, id, content):
     BlogCommentModel.update(id, content)
     self._expireCommentCache(id)
     return getFormatManager().noPluginFormat(content, True)
示例#11
0
 def __init__(self):
     getFormatManager().registerSLPlugin('page', self.handlePages)
     getFormatManager().registerSLPlugin('pagelink', self.handlePageLinks)
示例#12
0
 def renderComment(self, content):
     return getFormatManager().noPluginFormat(content, True)
示例#13
0
 def cmsRender(text):
     return getFormatManager().htmlFormat(text, edit_mode, False, page_obj)
示例#14
0
 def amiformat(cnt, var):
     script = re.compile('<(/?script)>', re.IGNORECASE)
     cnt = script.sub(r'&lt;\1&gt;', cnt)
     return getFormatManager().noPluginFormat(cnt, var)
示例#15
0
def wikiWords(args, edit_mode, current_page):
    from skeletonz.model import CMSModel as Model
    from skeletonz.Site import Users
    import skeletonz.model.visit as visit

    #Set the view
    btn_create_page = html_helpers.createActionLink(
        '', 'static_plugin/wikiplugin/page_add.png')
    btn_create_page = '<a href="siteedit/pageCreate?parent_id=$parent_id&$encode($ident)">%s</a>' % (
        html_helpers.createToolTip("Create page", btn_create_page, ""))

    btn_delete_page = html_helpers.createActionLink(
        'Delete page',
        'static_plugin/wikiplugin/page_delete.png',
        'return EC_Pages.remove(this, $obj.id)',
        'CMS_link CMS_critical_link',
        tooltip_inner=True,
        confirm="Are you sure you want to delete this page?")

    tmpl_new = """<span><span class="CMS_NotCreated">$normal_view</span> $edit_view %s</span>""" % btn_create_page
    tmpl_edit = """<span><a href="$BASE_URL/$obj.getFullLink()">$normal_view</a> $edit_view %s</span>""" % btn_delete_page
    tmpl_view = """<a href="$BASE_URL/$obj.getFullLink()">$normal_view</a>"""
    tmpl_view_not_created = """<span class="CMS_NotCreated">$normal_view</span>"""

    if args.has_key('page'):
        ident = args['page']
        if args.has_key('static') or args.has_key('global'):
            obj = Model.Pages.getPageGlobal(ident)
        else:
            obj = Model.Pages.getPage(ident, current_page.id)

        site_edit = ''
        if edit_mode:
            site_edit = '/siteedit'

        def encode(x):
            return urllib.urlencode({'name': x})

        normal_view = ident
        edit_view = ''

        if args.has_key('show_as'):
            show_as = args['show_as']
            if type(show_as) == types.DictType:
                if show_as['plugin_type'] == 'image':
                    if edit_mode:
                        normal_view = ident
                        edit_view = getFormatManager().imageEditModeLink(
                            show_as, edit_mode)
                    else:
                        normal_view = getFormatManager().imageEditModeLink(
                            show_as, edit_mode)
                        edit_view = ''
                else:
                    print 'ERROR: Only images are supported in [page=..., show_as=...]'
            else:
                normal_view = show_as

        ns = {
            'BASE_URL': "%s%s" % (getConfig().BASE_URL, site_edit),
            'ident': ident,
            'normal_view': normal_view,
            'edit_view': edit_view,
            'obj': obj,
            'parent_id': current_page and current_page.id or 1,
            'encode': encode
        }

        ns['normal_view'] = re.sub('\s*!\d', '', ns['normal_view'])

        if edit_mode == True:
            #Check if the obj if the page is created, switch on the views
            if obj == None:
                replacer = render(tmpl_new, ns, True)
            else:
                replacer = render(tmpl_edit, ns, True)
        else:
            #Check if the obj if the page is created, switch on the views
            if obj == None or obj.hidden == True:
                replacer = render(tmpl_view_not_created, ns, True)
            else:
                replacer = render(tmpl_view, ns, True)

    return replacer
示例#16
0
 def __init__(self):
     getFormatManager().registerSLPlugin('cmt', self.handle)
     getFormatManager().registerMLPlugin('comment', self.handle)
示例#17
0
 def generateContentEdit(self):
     if self.content == "" or self.content == None:
         self.generated_cnt_edit = '<p>This page has no content.</p>'
     else:
         self.generated_cnt_edit = getFormatManager().htmlFormat(
             self.content, True, True, self)
示例#18
0
    def __init__(self):
        self.data = None

        getFormatManager().registerMLPlugin('header_data', self.handleFilter)