Django双语博客
django-marcus的Python项目详细描述
简介
马库斯是一个双语博客引擎,作者是伊凡·萨加拉耶夫(http://softwaremaniacs.org/about/)。
此分叉扩展并具有以下功能:
- 双语文章、类别、标签和评论
- 带有预览图像的文章的简单文件上载程序
- 存档和日期导航
- 回拨
- 在新条目上自动ping搜索引擎
- 支持降价(http://pypi.python.org/pypi/markdown2)
- 评论通过javascript提供csrf保护,支持akismet(反垃圾邮件服务)
- 可以通过openid进行身份验证,也可以通过预先主持的登录进行身份验证
- 支持“转发”按钮
- 文章的站点地图、文章的提要和评论
- 一个简单的搜索模块
- 非常简约的主题
- 从wordpress导入(命令“wordpress_importer”)
示例
- http://softwaremaniacs.org/blog/(伊凡·萨加拉耶夫)
- https://prudnitskiy.pro/(帕维尔·鲁德尼茨基)
- http://adw0rd.com/(米哈伊尔安德列夫)
关于马库斯
安装
http://pypi.python.org/pypi/django-marcus
mkvirtualenv marcus pip install --process-dependency-links django-marcus # use "--process-dependency-links" for pip>=1.5 django-admin.py startproject <project_name>
配置
添加到settings.py:
import os import imp PROJECT_ROOT = os.path.dirname(__file__) PROJECT_NAME = os.path.basename(PROJECT_ROOT) STORAGE_ROOT = os.path.join('/storage', PROJECT_NAME) LOCALE_PATHS = ( os.path.join(imp.find_module('marcus')[1], 'locale'), ) ADMINS = ( ('Admin', 'admin@example.com'), ) // Please setup settings.MANAGERS for notify about new comments MANAGERS = ADMINS MARCUS_PAGINATE_BY = 20 MARCUS_ARTICLES_ON_INDEX = 10 MARCUS_COMMENTS_ON_INDEX = 10 MARCUS_COMMENT_EXCERPTS_ON_INDEX = 2 MARCUS_ITEMS_IN_FEED = 20 MARCUS_AUTHOR_ID = 1 MARCUS_TAG_MINIMUM_ARTICLES = 0 # Specify blog names: from django.utils.translation import ugettext_lazy as _ MARCUS_TITLE = _('Blog') MARCUS_SUBTITLE = _('Sample blog') MARCUS_DESCRIPTION = _('') MARCUS_KEYWORDS = _('') # You can specify extras for markdown: MARCUS_MARKDOWN_EXTRAS = ['code-friendly', 'wiki-tables'] # You can specify #hashtag or @name as suffix for Twitter: MARCUS_RETWEET_SUFFIX = "#marcus" # Specify a fields which will used in search: MARCUS_SEARCH_FIELDS = [ 'slug', 'title_ru', 'title_en', 'text_ru', 'text_en', 'categories__slug', 'categories__title_ru', 'categories__title_en', ] # OpenID sessions dir. OpenID authentication will not work without it. SCIPIO_STORE_ROOT = os.path.join(STORAGE_ROOT, 'scipio') # URL passed to OpenID-provider to identify site that requests authentication. # Should not end with '/'. # Complete site URL is passed if the value is empty. SCIPIO_TRUST_URL = '' # Akismet is a spam filtering service. # Without the key will not work comments. # You can receive the key here https://akismet.com/signup/ SCIPIO_AKISMET_KEY = '' SCIPIO_USE_CONTRIB_SITES = True AUTHENTICATION_BACKENDS = ( 'scipio.authentication.OpenIdBackend', 'django.contrib.auth.backends.ModelBackend', ) TEMPLATE_CONTEXT_PROCESSORS = ( 'django.contrib.auth.context_processors.auth', 'django.core.context_processors.request', 'marcus.context_processors.marcus_context', ) MEDIA_ROOT = os.path.join(STORAGE_ROOT, 'media') MEDIA_URL = '/media/' STATIC_ROOT = os.path.join(STORAGE_ROOT, 'static') STATIC_URL = '/static/' INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.admin', 'django.contrib.admindocs', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.flatpages', 'marcus', 'scipio', )
添加到urls.py:
from django.conf.urls import patterns, include, url from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^admin/', include(admin.site.urls)), url(r'^', include('marcus.urls')), ) urlpatterns += staticfiles_urlpatterns()
然后运行:
python ./manage.py runserver 8000
安装后,转到http://localhost:8000/admin/scipio/profile/并创建概要文件。
wordpress导入程序设置:
marcus包含“wordpress_importer”是一个命令,它将您的条目从wordpress导入到marcus。 它有一个内置的管道用于额外的过滤数据。
MARCUS_WORDPRESS_IMPORTER = { 'ARTICLE_PIPELINES': ( 'marcus.wordpress_importer.pipelines.CodecolorerToHighlightJsPipeline', 'marcus.wordpress_importer.pipelines.WpContentUploadsToMediaPipeline', 'marcus.wordpress_importer.pipelines.BbCodeDetector', 'marcus.wordpress_importer.pipelines.EscapeTheUnderscore', # 'marcus.wordpress_importer.pipelines.ChangeUrlToArticleForImagePipeline', # 'marcus.wordpress_importer.pipelines.RemoveImgClassPipeline', # 'marcus.wordpress_importer.pipelines.HtmlToMarkdownPipeline', ), # 'CATEGORY_PIPELINES': tuple(), # 'TAG_PIPELINES': tuple(), 'COMMENT_PIPELINES': ( 'marcus.wordpress_importer.pipelines.CodecolorerToHighlightJsPipeline', ), 'ALLOW_DOMAINS': ( # Used to determine the internal domain to import only local "wp-content/uploads", etc. 'my-old-blog-on-wordpress.org', 'www.my-old-blog-on-wordpress.org', ), }
如何启用所见即所得?
因为选择了编辑器markitup(http://markitup.jaysalvat.com/),所以需要安装django-markitup:
pip install django-markitup
现在,添加到您的settings.py:
INSTALLED_APPS = ( ... 'markitup', ) MARKITUP_FILTER = ('markdown2.markdown', {'safe_mode': True}) MARKITUP_SET = 'marcus/sets/markdown'
并添加到您的urls.py:
url(r'^markitup/', include('markitup.urls')),
就这些!
新项目的安装指南:
django-admin.py startproject project cd project pip install --process-dependency-links django-marcus # use "--process-dependency-links" for pip>=1.5 ... Copy the settings to settings.py and you urls to you urls.py described above ... python ./manage.py syncdb python ./manage.py createsuperuser python ./manage.py runserver 8000
转到https://akismet.com/signup/,获取key并在此处输入:
SCIPIO_AKISMET_KEY = '<key>'
安装后,转到http://localhost:8000/admin/scipio/profile/并创建概要文件。
mysql时区修复
如果您使用mysql并且在按url打开文章时遇到问题,则很可能您没有工作CONVERT_TZ,可以通过以下方法解决:
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
许可证
BSD许可。