Exemple #1
0
 def md2cms(self):
     from digipal.views import doc
     
     doc_slug = 'doc'
     self.update_cms_page(doc_slug, draft=True)
     
     for path in utils.get_all_files_under(doc.get_doc_root_path('digipal'), file_types='f', filters=self.options['filter'], extensions='md', can_return_root=True):
         print path
         info = doc.get_doc_from_md(utils.read_file(path))
         page = None
         if info:
             content = u'<div class="mddoc">%s</div>' % info['content']
             page = self.update_cms_page(info['title'], content, doc_slug)
         if page:
             print '  => # %s (%s)' % (page.id, page.slug)
Exemple #2
0
 def md2cms(self):
     from digipal.views import doc
     
     doc_slug = 'doc'
     self.update_cms_page(doc_slug, draft=True)
     
     for path in utils.get_all_files_under(doc.get_doc_root_path('digipal'), file_types='f', filters=self.options['filter'], extensions='md', can_return_root=True):
         print path
         info = doc.get_doc_from_md(utils.read_file(path))
         page = None
         if info:
             content = u'<div class="mddoc">%s</div>' % info['content']
             page = self.update_cms_page(info['title'], content, doc_slug)
         if page:
             print '  => # %s (%s)' % (page.id, page.slug)
Exemple #3
0
    def html2md(self):
        if len(self.args) < 2:
            print 'ERROR: missing path. Check help.'
            exit()
            
        path = self.args[1]
        
        from digipal.views import doc
        from django.utils.text import slugify

        for path in utils.get_all_files_under(path, file_types='f', filters=self.options['filter'], extensions=['html', 'htm'], can_return_root=True):
            info = doc.get_md_from_html(path)
            target = os.path.join(doc.get_doc_root_path('digipal'), slugify(info['title']))+'.md'
            if 'confluence-workbox' in target:
                continue
            utils.write_file(target, info['md'])
            print '%s\n  => %s' % (path, target)
            for f in info['files']:
                print '   + %s' % f 
Exemple #4
0
    def html2md(self):
        if len(self.args) < 2:
            print 'ERROR: missing path. Check help.'
            exit()
            
        path = self.args[1]
        
        from digipal.views import doc
        from django.utils.text import slugify

        for path in utils.get_all_files_under(path, file_types='f', filters=self.options['filter'], extensions=['html', 'htm'], can_return_root=True):
            info = doc.get_md_from_html(path)
            target = os.path.join(doc.get_doc_root_path('digipal'), slugify(info['title']))+'.md'
            if 'confluence-workbox' in target:
                continue
            utils.write_file(target, info['md'])
            print '%s\n  => %s' % (path, target)
            for f in info['files']:
                print '   + %s' % f