本文整理汇总了Python中waliki.models.Page类的典型用法代码示例。如果您正苦于以下问题:Python Page类的具体用法?Python Page怎么用?Python Page使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Page类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_content_saved_on_attribute_set
def test_content_saved_on_attribute_set(self):
page = Page(path='test.rst')
page.raw = rst
path = os.path.join(settings.WALIKI_DATA_DIR, 'test.rst')
self.assertEqual(page.abspath, path)
self.assertTrue(os.path.exists(path))
content = open(path).read()
self.assertEqual(content, rst)
开发者ID:BrunoMoreno,项目名称:waliki,代码行数:8,代码来源:test_models.py
示例2: test_link_explicit
def test_link_explicit(self):
s = settings.WALIKI_MARKUPS_SETTINGS.get('Markdown')
s['extension_configs']['wikilinks']['build_url'] = mock.Mock(return_value='xxx')
with mock.patch('waliki.models.settings') as s_mock:
s_mock.WALIKI_MARKUPS_SETTINGS.get.return_value = s
html = Page.preview('Markdown', 'a [[Link]]')
self.assertEqual(html, '<p>a <a class="wikilink" href="xxx">Link</a></p>\n')
开发者ID:BrunoMoreno,项目名称:waliki,代码行数:7,代码来源:test_models.py
示例3: version
def version(request, slug, version):
page = get_object_or_404(Page, slug=slug)
content = Git().version(page, version)
if not content:
raise Http404
form = PageForm(instance=page, initial={'message': _('Restored version @%s') % version, 'raw': content},
is_hidden=True)
content = Page.preview(page.markup, content)
return render(request, 'waliki/version.html', {'page': page,
'content': content,
'slug': slug,
'version': version,
'form': form})
开发者ID:JuloWaks,项目名称:waliki,代码行数:13,代码来源:views.py
示例4: handle
def handle(self, *args, **options):
extensions = [ext.strip() for ext in options["extensions"].split(",")]
ignored_dirs = [d.strip() for d in options["ignored_dirs"].split(",")]
for root, dirs, files in os.walk(WALIKI_DATA_DIR):
[dirs.remove(d) for d in ignored_dirs if d in dirs]
for filename in files:
if os.path.splitext(filename)[1] not in extensions:
continue
path = os.path.join(root.replace(WALIKI_DATA_DIR, ""), filename).strip("/")
if not Page.objects.filter(path=path).exists():
page = Page.from_path(path)
self.stdout.write("Created page %s for %s" % (page.get_absolute_url(), path))
# Deleted pages?
for page in Page.objects.all():
if not os.path.exists(page.abspath):
self.stdout.write("Deleted page %s (missing %s)" % (page.get_absolute_url(), page.path))
page.delete()
if Attachment:
class FakeAttachment(object):
def __init__(self, page):
self.page = page
for page in Page.objects.all():
path = os.path.join(settings.MEDIA_ROOT, WALIKI_UPLOAD_TO(FakeAttachment(page), ""))
if not os.path.exists(path):
continue
for filename in os.listdir(path):
if not os.path.isfile(os.path.join(path, filename)):
continue
file = WALIKI_UPLOAD_TO(FakeAttachment(page), filename)
if page.attachments.filter(file=file):
continue
attachment = Attachment.objects.create(page=page, file=file, filename=filename)
self.stdout.write("Created attachment %s for %s" % (attachment, page.slug))
for attachment in Attachment.objects.all():
if not os.path.exists(os.path.join(settings.MEDIA_ROOT, attachment.file.name)):
self.stdout.write(
"Missing %s from %s. Deleted attachment object" % (attachment, attachment.page.slug)
)
attachment.delete()
开发者ID:BrunoMoreno,项目名称:waliki,代码行数:45,代码来源:sync_waliki.py
示例5: handle
def handle(self, *args, **options):
extensions = [ext.strip() for ext in options['extensions'].split(',')]
ignored_dirs = [d.strip() for d in options['ignored_dirs'].split(',')]
for root, dirs, files in os.walk(WALIKI_DATA_DIR):
[dirs.remove(d) for d in ignored_dirs if d in dirs]
for filename in files:
if os.path.splitext(filename)[1] not in extensions:
continue
path = os.path.join(root.replace(WALIKI_DATA_DIR, ''), filename).strip('/')
if not Page.objects.filter(path=path).exists():
page = Page.from_path(path)
self.stdout.write('Created page %s for %s' % (page.get_absolute_url(), path))
for page in Page.objects.all():
if not os.path.exists(page.abspath):
self.stdout.write('Deleted page %s (missing %s)' % (page.get_absolute_url(), page.path))
page.delete()
开发者ID:JuloWaks,项目名称:waliki,代码行数:18,代码来源:sync_waliki.py
示例6: version
def version(request, slug, version, raw=False):
page = get_object_or_404(Page, slug=slug)
content = Git().version(page, version)
form = PageForm(instance=page, initial={'message': _('Restored version @%s') % version, 'raw': content},
is_hidden=True)
if raw:
return HttpResponse(json.dumps(content), content_type='application/json')
if content["raw"]:
content = Page.preview(page.markup, content["raw"])
else:
content = ''
return render(request, 'waliki/version.html', {'page': page,
'content': content,
'slug': slug,
'version': version,
'form': form})
开发者ID:rizotas,项目名称:waliki,代码行数:19,代码来源:views.py
示例7: test_body
def test_body(self):
page = Page(path='test.md', markup='Markdown')
page.raw = md
self.assertEqual(page.body, md_html)
开发者ID:JuloWaks,项目名称:waliki,代码行数:4,代码来源:test_models.py
示例8: test_missing_text
def test_missing_text(self):
html = Page.preview('reStructuredText', '`***`_')
self.assertIn('problematic', html)
开发者ID:BrunoMoreno,项目名称:waliki,代码行数:3,代码来源:test_models.py
示例9: test_preview
def test_preview(self):
self.assertEqual(Page.preview('Markdown', md), md_html)
开发者ID:BrunoMoreno,项目名称:waliki,代码行数:2,代码来源:test_models.py
示例10: test_path_populated_from_slug_if_not_given
def test_path_populated_from_slug_if_not_given(self):
page = Page(slug='some/slug')
page.save()
self.assertEqual(page.path, 'some/slug.rst')
开发者ID:BrunoMoreno,项目名称:waliki,代码行数:4,代码来源:test_models.py
示例11: test_slug_strip_slashes
def test_slug_strip_slashes(self):
page = Page(slug='/some/slug/')
page.save()
self.assertEqual(page.slug, 'some/slug')
开发者ID:BrunoMoreno,项目名称:waliki,代码行数:4,代码来源:test_models.py
示例12: test_link_explicit
def test_link_explicit(self):
html = Page.preview('reStructuredText', 'a link_')
self.assertEqual(html, '\n <p>a <a href="/link">link</a></p>\n')
开发者ID:mgaitan,项目名称:waliki,代码行数:3,代码来源:test_models.py
示例13: test_link_invalid_slug
def test_link_invalid_slug(self):
html = Page.preview('reStructuredText', '`***`_')
self.assertIn('problematic', html)
开发者ID:mgaitan,项目名称:waliki,代码行数:3,代码来源:test_models.py
示例14: test_link_indirect
def test_link_indirect(self):
html = Page.preview('reStructuredText', 'a text_\n\n.. _text: link_')
self.assertEqual(html, '\n <p>a <a href="/link">text</a></p>\n')
开发者ID:mgaitan,项目名称:waliki,代码行数:3,代码来源:test_models.py
示例15: test_link_indirect_anonymous
def test_link_indirect_anonymous(self):
html = Page.preview('reStructuredText', 'a `long text`__\n\n__ link_')
self.assertEqual(html, '\n <p>a <a href="/link">long text</a></p>\n')
开发者ID:mgaitan,项目名称:waliki,代码行数:3,代码来源:test_models.py
示例16: test_link_crossref
def test_link_crossref(self):
html = Page.preview('reStructuredText', ('a crossref_\n\n'
'.. _crossref:\n\n'
'the crossref target'))
self.assertEqual(html, ('\n <p>a <a href="#crossref">crossref</a></p>'
'\n <p id="crossref">the crossref target</p>\n'))
开发者ID:mgaitan,项目名称:waliki,代码行数:6,代码来源:test_models.py
示例17: test_link_indirect_embedded
def test_link_indirect_embedded(self):
html = Page.preview('reStructuredText', ('a `long text <meep_>`_\n\n'
'.. _meep: link_'))
self.assertEqual(html, '\n <p>a <a href="/link">long text</a></p>\n')
开发者ID:mgaitan,项目名称:waliki,代码行数:4,代码来源:test_models.py
注:本文中的waliki.models.Page类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论