围绕树导航构建的小型CMS,可向任何Django模型开放

coop-cms的Python项目详细描述


coop cms,一个真正可插入的cms

又是一个CMS?
  1. coop cms是围绕文章构建的。它定义了一个基本的抽象模型,因此您可以定义自己的模型。
  2. 它在一个很好的管理小部件中有一个网站树,可以让您订购文章和您在项目中定义的任何其他标准django模型。
  3. 基于树,您可以获得菜单导航、兄弟链接、面包屑等的模板标记

coop cms有一些姊妹应用程序,使其更可用:

  • coop_bar,一个可扩展的工具栏(相同的概念:任何你创建的应用程序都可以在工具栏中添加链接)
  • djaloha,一个基于Aloha Editor
  • colorbox,轻松集成jquery colorbox库。

快速启动

python 2.6+,django 1.3+必需

pip install coop-cms

安装

网址.py

在url.py文件的末尾,添加:

urlpatterns += patterns('',
    (r'^djaloha/', include('djaloha.urls')),
    (r'^', include('coop_cms.urls')),
    (r'^coop_bar/', include('coop_bar.urls')),
)

请注意,合作社CMS将处理任何页面弹头,除了那些你将定义之前。

设置.py

在settings.py中:

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'pagination.middleware.PaginationMiddleware',
    ...
)

TEMPLATE_CONTEXT_PROCESSORS = (
    "django.contrib.auth.context_processors.auth",
    "django.core.context_processors.debug",
    "django.core.context_processors.i18n",
    'django.core.context_processors.request',
    "django.core.context_processors.media",
    "django.core.context_processors.static",
    "django.contrib.messages.context_processors.messages",
    ...
)

AUTHENTICATION_BACKENDS = (
    'coop_cms.perms_backends.ArticlePermissionBackend',
    'django.contrib.auth.backends.ModelBackend', # Django's default auth backend
)

INSTALLED_APPS = (
    # Contribs
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    'django.contrib.admindocs',

    #3rd parties
    'south',
    'django_extensions',
    'sorl.thumbnail',
    'floppyforms',
    'pagination',
    'chosen', #optional but recommended. You must install it separately

    #apps
    'coop_bar',
    'djaloha',
    'colorbox',
    'coop_cms',

    #The coop_cms Article is an abstract model, you must define an Article in one of your app
    #We provide 2 apps that can be used if needed. Choose one or the other
    #'coop_cms.apps.basic_cms', #Nothing else than a concrete Article model.
    'coop_cms.apps.demo_cms', #A ready-to-use example app.

    #The app below make possible to create articles from a RSS feed. Add it if needed
    'coop_cms.apps.rss_sync',
)

#These are settings to customize the CMS behavior. The values are just examples and correspond to the demo_cms app.

#Define the Concrete Article to use. Not required if basic_cms is used
COOP_CMS_ARTICLE_CLASS = 'coop_cms.apps.demo_cms.models.Article'

#Define a custom form for Article editing. Not required if basic_cms is used
COOP_CMS_ARTICLE_FORM = 'coop_cms.apps.demo_cms.forms.ArticleForm'

#Make possible to customize the menus in the admin bar. Optional.
#If not defined, the tuple is build with the coop_bar_cfg modules of all INSTALLED_APPS
COOPBAR_MODULES = (
    'coop_cms.apps.demo_cms.my_coop_bar',
)

#Populate the urls when editing <a> tag in Aloha editor
DJALOHA_LINK_MODELS = (
    'demo_cms.Article',
)

# Optional: you can overload the aloha plugins used by coop_cms --> see djaloha docs for details
DJALOHA_PLUGINS = (
    "common/format",
    "common/highlighteditables",
)

# Optional: you can change the jquery version used by aloha --> see djaloha docs for details
DJALOHA_JQUERY = 'js/jquery.1.7.2.js'

# Optional : you can customize the whole behavior of aloha by proving the url of config file.
# It will overload the config provided by djaloha --> see djaloha for details
DJALOHA_INIT_URL = '/static/js/my_aloha_config.js'

#Default size of the article logo. Can be changed in template
COOP_CMS_ARTICLE_LOGO_SIZE = "128x128"

#Templates that can be used for an article
#It can be a tuple or a function returning a tuple
COOP_CMS_ARTICLE_TEMPLATES = 'coop_cms.apps.demo_cms.get_article_templates'
#COOP_CMS_ARTICLE_TEMPLATES = (
#    ('standard.html', 'Standard'),
#    ('homepage.html', 'Homepage'),
#    ('blog.html', 'Blog'),
#)

#Prefix for making absolute links
COOP_CMS_SITE_PREFIX = 'http://127.0.0.1:8000'

#from email : the domain of this address should allow the IP of your SMTP server : See SPF
COOP_CMS_FROM_EMAIL = '"Your name" <your@email.com>'

#TODO : REPLY-TO
COOP_CMS_REPLY_TO = '"Your name" <your@email.com>'

# Email address to send a newsletter test
COOP_CMS_TEST_EMAILS = (
    '"Your name" <your@email.com>',
)

#tuples of templates that can be used for a newsletter.
COOP_CMS_NEWSLETTER_TEMPLATES = (
    ('basic_newsletter.html', 'Basic'),
    ('special_newsletter.html', 'With sections'),
    ('sortable_newsletter.html', 'Sortable sections'),
)
#optional : A custom form for editing the newsletter
COOP_CMS_NEWSLETTER_FORM = 'coop_cms.apps.demo_cms.forms.SortableNewsletterForm'

基本模板

您需要在一个模板文件夹中创建一个基本模板base.htmlarticle.html将从此基本模板继承。

您需要以下模板标记库:

{% load coop_navigation coop_bar_tags %}

在文档的头中:

{% coop_bar_headers %}
{% block jquery_declaration %}{% endblock %}
{% block extra_head %}{% endblock %}

在文档的<;正文>;中:

{% block document %}...{% endblock %}
{% coop_bar %}

就在文档末尾的<;/正文>;之前:

{% coop_bar_footer %}

您还可以在<;正文>;中放置一些导航信息:

{% navigation_as_nested_ul %}
导航作为嵌套模板标记接受多个参数
  • tree=“english”–>;要使用的导航树的名称。“默认”如果缺少
  • li_template=“dropdown_li.html”–>;每个<;li>;标记的模板
  • ul_template=“dropdown_ul.html”–>;每个标签的模板
  • li_args=“dropdown_li_class.html”->;用于任何<;li>;标记的参数

还有其他用于导航的模板标记:navigation_breadcrumbnavigation_childrennavigation_siblings,其行为类似

更进一步

您可以查看apps文件夹中的demo_应用程序,了解如何自定义coop_cms的行为:
  • 页面中可编辑的“HTML片段”:可由多个页面共享的可编辑块。
  • 文章和新闻稿的自定义模板
  • 文章中的自定义字段
  • 自定义管理栏
  • 配置值

热门话题
java在应用程序中存储数据的最佳方式是什么,用户不会更新数据?   java RCP使用清晰的工作区启动产品   java JMockit:如何将模型类注入到测试类中?   java这个树结构将使用多少位?   java在实现actionListener的JPanel之间切换   JavaFX:为什么文本模糊?   javascript中的AES加密和java中的解密存在问题   java中的异常。朗。反思。javafx中的InvocationTargetException   java如何获取用于内部泛型类型的注释?   java Protobufnet和。原始文件?   java如何从json响应中获取特定对象   java没有响应。标题是否覆盖@products注释?   嵌入式Tomcat 8 war maven上的java“文件名过长错误”   java使用RxJava创建自定义观测值的正确方法[排序]?   java捕获ValidationException,而不是ControllerAdvice中的自定义异常   utf 8 java在处理带有BOM字符串的utf8时的不一致行为   java使用sysdate更新日期列,并在oracle中抛出Uniuqe约束。以日期为主键随机发生   JavaEE动态文件处理   安卓无法在未调用Looper的线程内创建处理程序。准备()