GoScale CMS is an extension of Django CMS.
It’s a set of unique plugins and useful tools for Django CMS that makes it very powerful by seamlessly integrating content from 3rd party websites like:
But it’s more than just content. GoScale plugins add some fancy functionality to make this content shine!
It’s perfect for quickly building Mashups and Media heavy sites.
Website: http://goscalecms.com
GitHub repository: https://github.com/sternoru/goscalecms
Google Group: https://groups.google.com/forum/?fromgroups#!forum/goscale-cms
Note:
When installing the GoScale CMS using pip, Django, django-cms, pytz, unidecode, BeautifulSoup, feedparser and gdata will be installed automatically.
We’re assuming you’re already running a functional version of Django CMS. If not, follow their tutorial first:
Add “goscale” and desired plugins to your INSTALLED_APPS setting like this:
INSTALLED_APPS = (
...
'goscale',
'goscale.plugins.videos',
'goscale.plugins.pictures',
'goscale.plugins.feeds',
'goscale.plugins.forms',
'goscale.plugins.calendar',
'goscale.plugins.presentations',
)
Add GoScale URL patterns:
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^goscale/', include('goscale.urls')),
url(r'^', include('cms.urls')),
)
Now if you run you Django server you should have GoScale plugins available for your CMS placeholders.
Contrary to Django CMS, GoScale plugins support multiple templates for one plugin. It’s a powerful tool for customization.
All plugins have following optional fields by default:
And following system fields that never show up in Django admin:
Application: ‘goscale.plugins.calendar’
Configuration options:
Templates:
Single post template: event.html
Additional templates can be added by setting GOSCALE_CALENDAR_CUSTOM_PLUGIN_TEMPLATES tuple in your settings.py
Application: ‘goscale.plugins.feeds’
Configuration options:
Templates:
Single post template: post.html (default)
Additional templates can be added by setting GOSCALE_FEEDS_CUSTOM_PLUGIN_TEMPLATES tuple in your settings.py
Application: ‘goscale.plugins.feeds’
Configuration options:
Templates:
Single post template: post.html (default)
Additional templates can be added by setting GOSCALE_FEEDS_CUSTOM_PLUGIN_TEMPLATES tuple in your settings.py
Application: ‘goscale.plugins.forms’
Configuration options:
Templates:
Additional templates can be added by setting GOSCALE_FORMS_CUSTOM_PLUGIN_TEMPLATES tuple in your settings.py
Application: ‘goscale.plugins.pictures’
Configuration options:
Templates:
Additional templates can be added by setting GOSCALE_PICTURES_CUSTOM_PLUGIN_TEMPLATES tuple in your settings.py
Application: ‘goscale.plugins.videos’
Configuration options:
Templates:
Additional templates can be added by setting GOSCALE_VIDEOS_CUSTOM_PLUGIN_TEMPLATES tuple in your settings.py
Application: ‘goscale.plugins.presentations’
Configuration options:
Templates:
Additional templates can be added by setting GOSCALE_PRESENTATIONS_CUSTOM_PLUGIN_TEMPLATES tuple in your settings.py
Application: ‘goscale.plugins.presentations’
Configuration options:
Templates:
Additional templates can be added by setting GOSCALE_PRESENTATIONS_CUSTOM_PLUGIN_TEMPLATES tuple in your settings.py
GOSCALE_VIDEOS_CUSTOM_PLUGIN_TEMPLATES
Additional templates list for goscale.plugins.videos. (default: ())
GOSCALE_CALENDAR_CUSTOM_PLUGIN_TEMPLATES
Additional templates list for goscale.plugins.calendar. (default: ())
GOSCALE_FEEDS_CUSTOM_PLUGIN_TEMPLATES
Additional templates list for goscale.plugins.feeds. (default: ())
GOSCALE_FORMS_CUSTOM_PLUGIN_TEMPLATES
Additional templates list for goscale.plugins.forms. (default: ())
GOSCALE_PICTURES_CUSTOM_PLUGIN_TEMPLATES
Additional templates list for goscale.plugins.pictures. (default: ())
GOSCALE_DEFAULT_POST_PLUGIN
Default template to use for a single post. (default: ‘post.html’)
GOSCALE_POSTS_UPDATE_FREQUENCY
How often to update posts for plugins. (default: 60*30, 30 minutes)
GOSCALE_UPDATE_FROM_ADMIN
Should GoScale update posts right after saving the plugin in Django admin. (default: False)
GOSCALE_CACHE_DURATION
Cache duration for plugins content. (default: CMS_CACHE_DURATIONS[‘content’], the same as content cache duration in Django CMS)
GOSCALE_POST_SUMMARY_LIMIT
Where to trim post summary text. (default: 300)
GOSCALE_DEFAULT_PAGE_SIZE
Default number of posts per page. (default: 10)
GOSCALE_DEFAULT_CONTENT_ORDER
Default sorting for posts. (default: ‘-published’)
SITE_ALIASES
Allows to enable multiple hosts for one theme (for example local, dev, staging servers).
THEME
Sets currently enabled default theme (if not set by request).
All the commands in GoScale CMS are grouped under one command “goscale”. Run it with –help option to list all available commands:
python manage.py goscale --help
Re-saves all posts for all GoScale plugins and re-generates slugs based on post titles and IDs.
Usage:
python manage.py goscale update_slugs
Updates posts for all GoScale plugins.
You can put run it manually or as a cron job to keep your plugins content up-to-date and cached. But the best way to do it is by using Celery task queue!
Available options:
Usage:
python manage.py goscale update_posts --site=2
The best way to keep your content up-to-date is by running a Celery worker that will update and cache all the plugins.
It’s easy to get it up and running.
Install the django-celery library:
pip install django-celery
Add the following lines to settings.py:
import djcelery
djcelery.setup_loader()
Add ‘djcelery’ to INSTALLED_APPS.
syncdb or migrate if you’re using south:
python manage.py migrate djcelery
Configure your tasks in settings.py:
BROKER_URL = 'amqp://guest:guest@localhost:5672/' # if you're using RabbitMQ
CELERY_IMPORTS = ("goscale.tasks", )
If you want a task to update GoScale plugins to be sent immediately after plugin was saved in the Django admin add this in your settings:
GOSCALE_UPDATE_FROM_ADMIN = True
If you want to setup a schedule for updating, configure Celery Beat:
from celery.schedules import crontab
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler' # or whatever you prefer
CELERYBEAT_SCHEDULE = {
"update_goscale_plugins": {
"task": "goscale.tasks.update_goscale_plugins",
"schedule": crontab(minute='*/30'), # every 30 minutes
"args": ()
},
}
Run your worker and celery beat:
python manage.py celery worker -B
For more detailed information refer to Celery documentation.
Periodic task that goes through all goscale plugins and sends tasks to update them.
Updates posts for a single plugin.
Usually scheduled by update_goscale_plugins task or when saving a plugin from Django admin.
Usage of GoSCale template tags is optional but can provide some useful functionality.
Tag library for GoScale is called “goscale_tags”:
{% load goscale_tags %}
Provides a simple reusable pagination for GoScale plugin posts.
Simple case:
{% goscale_paginator %}
Custom template:
{% goscale_paginator template="infinite_scrolling.html" %}
Tag: goscale_paginator
Template: paginator.html
Keyword arguments:
Context variables:
Note: if you want a full unfiltered list of all pages just use {{ paginator.page_range }}
If your plugin uses any complex filters or query string params for it’s data you can use this tag to generate links to pass these filters to your plugin (or even all plugins on a page with the “global” param).
It renders the whole query string with added filters for the current plugin so any other query string params will be preserved. You can ignore this default behavior by using “exclusive” param.
One of the examples is in the paginator tag to generate page links and in calendar plugin to generate start date links.
Page link:
<a href="{% goscale_plugin_filters page=page.previous_page_number %}">{% trans "Prev" %}</a>
Calendar date example:
<a href="{% goscale_plugin_filters start=start_date global='true' exclusive='true' %}">{{start_date}}</a>
Tag: goscale_plugin_filters
Keyword arguments:
Used to render a link for a single post.
Simply an extension of Django CMS placeholder tag. It acts exactly the same but allows you to define if you want to render single posts into this placeholder.
For example if you want to render posts from “sidebar” placeholder plugins into “content” placeholder which can often be a case.
If you don’t use it you will still be able to access single posts inside of your plugin in a {{ post }} context variable.
Same result as Django CMS placeholder:
{% goscale_placeholder content %}
Placeholder where to render single posts:
{% goscale_placeholder content render_posts='true' %}
Tag: goscale_placeholder
Keyword arguments:
Simply an extension of django-sekizai addtoblock tag. It acts exactly the same but allows you to use it with AJAX requests.
If a CMS plugin where you use it will be rendered inside of an AJAX request it will simply render the contents of addtoblock tag instead of adding them into page context which wouldn’t work with ajax anyway.
Renders a user bar for Login and Registration links and User Info.
Simple case:
{% goscale_user %}
Custom template:
{% goscale_user template="userbar.html" %}
Tag: goscale_user
Template: user/user.html
Keyword arguments:
Renders a Login Form to use outside of the /accounts/login/ page.
Simple case:
{% goscale_login %}
Custom template:
{% goscale_login template="custom_login.html" %}
Tag: goscale_login
Template: user/login.html
Keyword arguments:
All the plugins are located in the goscalecms app “goscale” folder, then in “plugins”. There is also a second subfolder, “static” containing the media files used by these plugins (js, css and images).
The “plugins” folder contains all the plugins (each plugin having its own folder at its name). In their “templates” sub folders are their templates, each one corresponding to a specific view, that you can choose in the “template” dropdown of a plugin in the admin.
In all these templates you have access to 2 main variables :
Then, each plugin has it’s own specific secondary variables to display additional information or choose a specific layout.
For each new plugin, always use the same structure as the other plugin’s templates (to include the base css and js files). To include plugin’s specific js and css files (used by dependencies like jquery plugins), use these URLs:
{{ STATIC_URL }}goscale/css/your.css.file.css
{{ STATIC_URL }}goscale/js/your.js.file.js
Also, if your plugin needs you to add specific css to make its default style and/or specific js to make it run, use these URLs:
{{ STATIC_URL }}goscale/css/goscale.plugins.pluginname.css
{{ STATIC_URL }}goscale/js/goscale.plugins.pluginname.js
In these URLs, replace pluginname by the name of your plugin.
They should all be in the “static” subfolder, in “js” for the javascript files, “css” for the css files and “img” for the images.
In the specific js file, you should create a jquery plugin that’s called only if a certain class is found on the page, example:
(function($) {
$.fn.goscalePluginsVideos = function() { // jquery plugin creation
// your plugin's js here
};
$(function() {
$('.goscale-plugins-videos').goscalePluginsVideos(); // check for the specific class to run the jquery plugin
});
})(jQuery);
In order to make the ajaxlinks plugin work with the goscale’s plugins, you’ll need to add a “data-callback” attribute to the javascript files in your plugin’s template containing the name of the function you need to call each time a page containing your plugin is loaded. Example:
<script type="text/javascript" src="{{ STATIC_URL }}goscale/js/goscale.plugins.videos.js" data-callback="plugins.goscalePluginsVideos"></script>
It’s possible to enable different themes for different sites using ‘goscale.themes’ app.
It’s a combination of modified django-cms-themes and django-dynamicsites
Currently it’s possible to theme:
To use themes add ‘goscale.themes’ to INSTALLED_APPS:
INSTALLED_APPS = (
...
'goscale',
'goscale.themes',
)
Add ‘static’ context processor:
TEMPLATE_CONTEXT_PROCESSORS = (
...
'goscale.themes.context_processors.static',
)
Add ‘SiteOnFlyDetectionMiddleware’ middleware before any other:
MIDDLEWARE_CLASSES = (
'goscale.themes.site_middleware.SiteOnFlyDetectionMiddleware',
...
)
Create a new Theme in django admin and upload a theme tarball (tar.gz) file or put your theme files into ‘themes’ directory in your project and input the theme name.
Choose a Site to which this theme should apply.
After that you should have theme templates in your Page editing form.
For more information refer to django-cms-themes website.
For theme static files:
{{ STATIC_THEME_URL }}
For current theme name:
{{ GOSCALE_THEME }}
The beauty of goscale.themes app is that you can serve multiple themes and sites from the same django project instance. It’s enabled by SiteOnFlyDetectionMiddleware from django-dynamicsites.
You can switch themes dynamically by hosts in your browser.
For more information refer to django-dynamicsites documentation.
To enable multiple hosts for one theme (for example local, dev, staging servers) use SITE_ALIASES setting:
SITE_ALIASES = {
'goscalecms.ru': 'goscalecms.com',
}
The pattern for theme switching locally is:
{{theme}}.127.0.0.1.xip.io:{{port}}
So let’s say you’re running your server on localhost:8000. And you want to open theme goscale, then open:
http://goscale.127.0.0.1.xip.io:8000/
You can use any auth app for django but if you want a quick and easy setup with GoScale you’re in luck - we support django-allauth (only version 0.9 at the moment)! Which is one of the most convenient apps to handle all of your user account needs. We also added a few template tags and utils for it to make it easier to use.
Just follow the tutorial from django-allauth README. Here’s a brief summary:
Install django the requirements:
pip install django-allauth==0.9.0 django-avatar
./manage.py syncdb
./manage.py migrate
settings.py:
TEMPLATE_CONTEXT_PROCESSORS = (
...
"django.core.context_processors.request",
...
"allauth.account.context_processors.account",
"allauth.socialaccount.context_processors.socialaccount",
...
)
AUTHENTICATION_BACKENDS = (
...
# Needed to login by username in Django admin, regardless of `allauth`
"django.contrib.auth.backends.ModelBackend",
# `allauth` specific authentication methods, such as login by e-mail
"allauth.account.auth_backends.AuthenticationBackend",
...
)
INSTALLED_APPS = (
...
'avatar',
'allauth',
'allauth.account',
'allauth.socialaccount',
# ... include the providers you want to enable:
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.github',
'allauth.socialaccount.providers.linkedin',
'allauth.socialaccount.providers.openid',
'allauth.socialaccount.providers.persona',
'allauth.socialaccount.providers.soundcloud',
'allauth.socialaccount.providers.stackexchange',
'allauth.socialaccount.providers.twitter',
'allauth.socialaccount.providers.weibo',
...
)
urls.py:
urlpatterns = patterns('',
...
(r'^accounts/', include('allauth.urls')),
(r'^goscale/', include('goscale.urls')),
...
)
Example settings (consult the docs for more customizaton):
LOGIN_REDIRECT_URL = '/'
ACCOUNT_AUTHENTICATION_METHOD = 'username_email'
ACCOUNT_EMAIL_VERIFICATION = 'optional'
SOCIALACCOUNT_PROVIDERS = {
'google': {
'SCOPE': [
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/userinfo.email'
],
'AUTH_PARAMS': { 'access_type': 'online' }
}
}
Make sure to create social apps in the admin for all the providers you choose.
You can use it as is the way intended by django-allauth . Or you can use GoScale combined Sign In / Sign Up view:
{% load url from future %}
{% load i18n %}
{% load account %}
<a href="{% url 'goscale_account_signup' %}" rel="next">{% trans "Log in" %} / {% trans "Register" %}</a>
We also already have a template tag that handles the whole “User bar”:
{% load goscale_tags %}
{% goscale_user %}