Ejemplo n.º 1
0
    def __init__(self, context):
        super(SignUp, self).__init__(context, _('title_home'))

        form = new.form(method='POST')
        table = VerticalTable()
        form.add(table)
        self.body.add(form)
        
        table.add(csrf_token(self.c.request))
        table.add(new.input(name='username', value='username', type='text'))
        table.add(new.input(name='password', value='password', type='password'))
        table.add(new.button(type='submit').add(_('Sign Up')))
Ejemplo n.º 2
0
    def __init__(self, context):
        super(SignUp, self).__init__(context, _('title_home'))

        form = new.form(method='POST')
        table = VerticalTable()
        form.add(table)
        self.body.add(form)

        table.add(csrf_token(self.c.request))
        table.add(new.input(name='username', value='username', type='text'))
        table.add(new.input(name='password', value='password',
                            type='password'))
        table.add(new.button(type='submit').add(_('Sign Up')))
Ejemplo n.º 3
0
    def __init__(self, context, contributions):
        self.contributions = contributions
        super(Home, self).__init__(context, _('title_home'))

        if self.c.user.is_authenticated():
            self.body.add('hello %s ' % self.c.user.username)
            self.body.add(new.a(href=self.c.get_url('inbox')
                                ).add('Inbox'))
            self.body.add(new.a(href=self.c.get_url('compose')
                            ).add('compose'))
            self.body.add(new.a(href=self.c.get_url('drafts')
                            ).add('drafts'))
            self.body.add(new.a(href=self.c.get_url('signout')
                            ).add('Sign Out'))
        else:
            self.body.add(new.a(href=self.c.get_url('signup')
                            ).add('Sign Up'))
            self.body.add(new.a(href=self.c.get_url('signin')
                            ).add('Sign In'))
        
        table = VerticalTable()
        self.body.add(table)
        
        for doc in self.contributions:
            p = new.p
            table.add(p)
            a = new.a(href=self.c.get_url('doc', id=doc.contribution)).add(doc.title)
            p.add(a)
            p.add(' (')
            a = new.a(href=self.c.get_url('edit', id=doc.contribution)).add('edit')
            p.add(a)
            p.add(') ')
Ejemplo n.º 4
0
    def __init__(self, context, contributions):
        self.contributions = contributions
        super(Home, self).__init__(context, _('title_home'))

        if self.c.user.is_authenticated():
            self.body.add('hello %s ' % self.c.user.username)
            self.body.add(new.a(href=self.c.get_url('inbox')).add('Inbox'))
            self.body.add(new.a(href=self.c.get_url('compose')).add('compose'))
            self.body.add(new.a(href=self.c.get_url('drafts')).add('drafts'))
            self.body.add(
                new.a(href=self.c.get_url('signout')).add('Sign Out'))
        else:
            self.body.add(new.a(href=self.c.get_url('signup')).add('Sign Up'))
            self.body.add(new.a(href=self.c.get_url('signin')).add('Sign In'))

        table = VerticalTable()
        self.body.add(table)

        for doc in self.contributions:
            p = new.p
            table.add(p)
            a = new.a(href=self.c.get_url('doc', id=doc.contribution)).add(
                doc.title)
            p.add(a)
            p.add(' (')
            a = new.a(
                href=self.c.get_url('edit', id=doc.contribution)).add('edit')
            p.add(a)
            p.add(') ')
Ejemplo n.º 5
0
 def _make_form(self):
     form = new.form(id="composer_form", method="POST")
     
     form.add(csrf_token(self.c.request))
     form.add(new.input(type="text", name="title", value=self.contrib['title'] or 'title'))
     form.add(new.div(id="composer"))
     form.add(new.textarea(id="basic_composer", name="content", style="height:400px;position:relative;").
              add(self.contrib.get_draft_text(self.c.user) or 'content'))
     form.add(new.button(type='submit').add(_('submit_publish')))
     form.add(new.input(type='submit', value=_('submit_save'), name="save"))
     form.add(new.input(type='submit', value=_('discard'), name="discard"))
     
     # Optional
     form.add(new.input(type='text', value=self.contrib.domain or _('domain'), name="domain"))
     # Optional
     form.add(new.input(type='text', value=self.contrib.uri or _('uri'), name="uri"))
     # Optional
     is_public = new.input(id='is_public', type='checkbox', value='true', 
                        name="is_public")
     if self.contrib['is_public']: is_public.set(checked='checked')
     form.add(is_public)
     form.add(new.label(fr='is_public').add(_('is_public')))
     
     # only for new contributions
     #TODO: support some switching
     if '_id' not in self.contrib:
         select = new.select(id="type_select",name='type')
         for type in ('plain', 'html', 'css', 'javascript', 'markdown'):
             option = new.option(value=type).add(_('cont_type_name_%s' % type))
             select.add(option)
         form.add(select)
     
     return form
Ejemplo n.º 6
0
 def init(self):
     self.head.addHTML('''
     <script src="/js/pluma.js" type="text/javascript" charset="utf-8"></script>
     <script>
         window.onload = function () {
             window.p = new Pluma();
             p.init();
             p.resizeInboxDoc("%(iframe_id)s");
         }
     </script>
     ''' % {'iframe_id': 'inbox_doc'})
     self.top.insert(
         0,
         new.a(href=self.c.get_url('edit', id=self.contribution_id)).add(
             _('edit')))
Ejemplo n.º 7
0
    def __init__(self, context, contributions):
        self.contributions = contributions
        super(Drafts, self).__init__(context, _('title_drafts'))

        table = VerticalTable()
        self.center.add(table)

        for doc in self.contributions:
            p = new.p
            table.add(p)
            if hasattr(doc, 'contribution') and doc.contribution:
                url = self.c.get_url('edit', id=doc.contribution)
            else:
                url = self.c.get_url('draft', id=doc._id)
            a = new.a(href=url).add(doc.title)
            p.add(a)
Ejemplo n.º 8
0
    def __init__(self, context, contributions):
        self.contributions = contributions
        super(Drafts, self).__init__(context, _('title_drafts'))

        table = VerticalTable()
        self.center.add(table)
        
        for doc in self.contributions:
            p = new.p
            table.add(p)
            if hasattr(doc, 'contribution') and doc.contribution:
                url = self.c.get_url('edit', id=doc.contribution)
            else:
                url = self.c.get_url('draft', id=doc._id)
            a = new.a(href=url).add(doc.title)
            p.add(a)
Ejemplo n.º 9
0
    def _make_form(self):
        form = new.form(id="composer_form", method="POST")

        form.add(csrf_token(self.c.request))
        form.add(
            new.input(type="text",
                      name="title",
                      value=self.contrib['title'] or 'title'))
        form.add(new.div(id="composer"))
        form.add(
            new.textarea(id="basic_composer",
                         name="content",
                         style="height:400px;position:relative;").add(
                             self.contrib.get_draft_text(self.c.user)
                             or 'content'))
        form.add(new.button(type='submit').add(_('submit_publish')))
        form.add(new.input(type='submit', value=_('submit_save'), name="save"))
        form.add(new.input(type='submit', value=_('discard'), name="discard"))

        # Optional
        form.add(
            new.input(type='text',
                      value=self.contrib.domain or _('domain'),
                      name="domain"))
        # Optional
        form.add(
            new.input(type='text',
                      value=self.contrib.uri or _('uri'),
                      name="uri"))
        # Optional
        is_public = new.input(id='is_public',
                              type='checkbox',
                              value='true',
                              name="is_public")
        if self.contrib['is_public']: is_public.set(checked='checked')
        form.add(is_public)
        form.add(new.label(fr='is_public').add(_('is_public')))

        # only for new contributions
        #TODO: support some switching
        if '_id' not in self.contrib:
            select = new.select(id="type_select", name='type')
            for type in ('plain', 'html', 'css', 'javascript', 'markdown'):
                option = new.option(value=type).add(
                    _('cont_type_name_%s' % type))
                select.add(option)
            form.add(select)

        return form
Ejemplo n.º 10
0
 def __init__(self, context, contrib):
     self.contrib = contrib
     super(Compose, self).__init__(context, _('title_compose'))
     self.center.add(self._make_form())
     
     self.head.addHTML('''
     <script src="/js/jquery-1.5.1.min.js" type="text/javascript" charset="utf-8"></script>
     <script src="/js/ace/ace.js" type="text/javascript" charset="utf-8"></script>
     <script src="/js/ace/mode-html.js" type="text/javascript" charset="utf-8"></script>
     <script src="/js/ace/theme-eclipse.js" type="text/javascript" charset="utf-8"></script>
     <script src="/js/pluma.js" type="text/javascript" charset="utf-8"></script>
     <script>
         window.onload = function () {
             window.p = new Pluma({ace:true});
             p.init();
             p.initComposer('composer', 'basic_composer', 'composer_form');
             p.setEditorMode('%(mode)s');
         }
     </script>
     ''' % {'mode' : self.contrib.mode or 'plain'})
Ejemplo n.º 11
0
    def __init__(self, context, contrib):
        self.contrib = contrib
        super(Compose, self).__init__(context, _('title_compose'))
        self.center.add(self._make_form())

        self.head.addHTML('''
        <script src="/js/jquery-1.5.1.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="/js/ace/ace.js" type="text/javascript" charset="utf-8"></script>
        <script src="/js/ace/mode-html.js" type="text/javascript" charset="utf-8"></script>
        <script src="/js/ace/theme-eclipse.js" type="text/javascript" charset="utf-8"></script>
        <script src="/js/pluma.js" type="text/javascript" charset="utf-8"></script>
        <script>
            window.onload = function () {
                window.p = new Pluma({ace:true});
                p.init();
                p.initComposer('composer', 'basic_composer', 'composer_form');
                p.setEditorMode('%(mode)s');
            }
        </script>
        ''' % {'mode': self.contrib.mode or 'plain'})
Ejemplo n.º 12
0
 def __init__(self, context, contributions):
     self.contributions = contributions
     super(Inbox, self).__init__(context, _('title_home'))
Ejemplo n.º 13
0
 def init(self):
     self.head.addHTML('''
     <script src="/js/pluma.js" type="text/javascript" charset="utf-8"></script>
     <script>
         window.onload = function () {
             window.p = new Pluma();
             p.init();
             p.resizeInboxDoc("%(iframe_id)s");
         }
     </script>
     ''' % {'iframe_id' : 'inbox_doc'})
     self.top.insert(0, new.a(href=self.c.get_url('edit', id=self.contribution_id)).add(_('edit')))
Ejemplo n.º 14
0
 def __init__(self, context, contributions):
     self.contributions = contributions
     super(Inbox, self).__init__(context, _('title_home'))