diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 10ecc8fcce2..e6dfc5953a9 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -194,7 +194,7 @@ Organizations based authorization (see :doc:`authorization`): * New authorization ini file options -New frontend (see :doc:`theming`): +New frontend (see :doc:`theming/index`): CKAN's frontend has been completely redesigned, inside and out. There is a new default theme and the template engine has moved from Genshi to Jinja2. Any custom templates using Genshi will need to be updated, although diff --git a/ckan/plugins/interfaces.py b/ckan/plugins/interfaces.py index 14d64b01146..f3dfce7d962 100644 --- a/ckan/plugins/interfaces.py +++ b/ckan/plugins/interfaces.py @@ -770,7 +770,7 @@ def read_template(self): If the user requests the dataset in a format other than HTML (CKAN supports returning datasets in RDF or N3 format by appending .rdf - or .n3 to the dataset read URL, see :doc:`linked-data-and-rdf`) then + or .n3 to the dataset read URL, see :doc:`/linked-data-and-rdf`) then CKAN will try to render a template file with the same path as returned by this function, but a different filename extension, e.g. ``'package/read.rdf'``. diff --git a/ckan/plugins/toolkit.py b/ckan/plugins/toolkit.py index 34e9d671cf1..3e5ba71f8f8 100644 --- a/ckan/plugins/toolkit.py +++ b/ckan/plugins/toolkit.py @@ -216,7 +216,7 @@ def _initialize(self): def _render_snippet(cls, template, data=None): '''Render a template snippet and return the output. - See :doc:`/theming`. + See :doc:`/theming/index`. ''' data = data or {} @@ -266,7 +266,7 @@ def _add_resource(cls, path, name): Fanstatic libraries are directories containing static resource files (e.g. CSS, JavaScript or image files) that can be accessed from CKAN. - See :doc:`/theming` for more details. + See :doc:`/theming/index` for more details. ''' # we want the filename that of the function caller but they will diff --git a/doc/conf.py b/doc/conf.py index 22e1049600a..b5f78af3ac7 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -58,6 +58,10 @@ .. |javascript| replace:: JavaScript .. |apache| replace:: Apache +.. _Jinja2: http://jinja.pocoo.org/ +.. _CKAN front page: http://127.0.0.1:5000 +.. _bootstrap: http://getbootstrap.com/2.3.2/ + ''' # Add any Sphinx extension module names here, as strings. They can be extensions diff --git a/doc/configuration.rst b/doc/configuration.rst index 8cf90b9ab2d..1c76289685a 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -655,7 +655,7 @@ Format tips: * the format is Markdown .. note:: Whilst the default text is translated into many languages (switchable in the page footer), the text in this configuration option will not be translatable. - For this reason, it's better to overload the snippet in ``home/snippets/about_text.html``. For more information, see :doc:`theming`. + For this reason, it's better to overload the snippet in ``home/snippets/about_text.html``. For more information, see :doc:`theming/index`. .. _ckan.main_css: @@ -951,7 +951,7 @@ Example:: To customise the display of CKAN you can supply replacements for the Genshi template files. Use this option to specify where CKAN should look for additional templates, before reverting to the ``ckan/templates`` folder. You can supply more than one folder, separating the paths with a comma (,). -For more information on theming, see :doc:`theming`. +For more information on theming, see :doc:`theming/index`. .. _extra_public_paths: @@ -964,7 +964,7 @@ Example:: To customise the display of CKAN you can supply replacements for static files such as HTML, CSS, script and PNG files. Use this option to specify where CKAN should look for additional files, before reverting to the ``ckan/public`` folder. You can supply more than one folder, separating the paths with a comma (,). -For more information on theming, see :doc:`theming`. +For more information on theming, see :doc:`theming/index`. .. end_config-theming diff --git a/doc/index.rst b/doc/index.rst index e0167318ecb..2ec40ed7af9 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -19,7 +19,7 @@ advanced documentation last: beyond those that just work out of the box. These are for **sysadmins** who want to learn how to manage and get more out of their CKAN site. -* :doc:`extensions/index`, :doc:`theming` and :doc:`api` are advanced docs +* :doc:`extensions/index`, :doc:`theming/index` and :doc:`api` are advanced docs for **developers** who want to develop an extension, theme or API app using CKAN. @@ -39,7 +39,7 @@ advanced documentation last: getting-started features extensions/index - theming + theming/index api contributing test diff --git a/doc/tag-vocabularies.rst b/doc/tag-vocabularies.rst index f86d4332aaa..4a467808b78 100644 --- a/doc/tag-vocabularies.rst +++ b/doc/tag-vocabularies.rst @@ -65,6 +65,6 @@ To add a tag vocabulary to a site, a CKAN sysadmin must: 3. Provide custom dataset templates to display the new field to users when adding, updating or viewing datasets in the CKAN web interface. - See :doc:`theming`. + See :doc:`theming/index`. See ``ckanext/example_idatasetform`` for a working example of these steps. diff --git a/doc/template-helper-functions.rst b/doc/template-helper-functions.rst deleted file mode 100644 index 77a36f972dc..00000000000 --- a/doc/template-helper-functions.rst +++ /dev/null @@ -1,7 +0,0 @@ -========================= -Template helper functions -========================= - -.. automodule:: ckan.lib.helpers - :members: - :undoc-members: diff --git a/doc/theming/css.rst b/doc/theming/css.rst new file mode 100644 index 00000000000..e2add6e26f3 --- /dev/null +++ b/doc/theming/css.rst @@ -0,0 +1,63 @@ +====================== +Customizing CKAN's CSS +====================== + +Extensions can add their own CSS files to modify or extend CKAN's default CSS. +Create an ``example_theme.css`` file in your extension's ``public`` directory:: + + ckanext-example_theme/ + public/ + example_theme.css + +Add this CSS into the ``example_theme.css`` file, to change the color of CKAN's +"account masthead" (the bar across the top of the site that shows the logged-in +user's account info): + +.. literalinclude:: /../ckanext/example_theme/v12_custom_css/public/example_theme.css + +If your restart the development web server (kill the server using Ctrl-c, then +run the ``paster serve`` command again) you should be able to open this file at +http://127.0.0.1:5000/example_theme.css in a web browser. + +To make CKAN use our custom CSS we need to override the ``base.html`` template, +this is the base template which the templates for all CKAN pages extend, so if +we include a CSS file in this base template then the file will be included in +every page of your CKAN site. Create the file:: + + ckanext-example_theme/ + templates/ + base.html + +and put this Jinja code in it: + +.. literalinclude:: /../ckanext/example_theme/v12_custom_css/templates/base.html + +The default ``base.html`` template defines a ``styles`` block which can be +extended to link to custom CSS files (any code in the styles block will appear +in the ``
`` of the HTML page). + +Restart the development web server, and you should see the background color of +the account masthead change. This custom color should appear on all pages of +your CKAN site. + +Now that we have CKAN using our CSS file, we can add more CSS rules to the file +and customize CKAN's CSS as much as we want. There's nothing special about CSS +in CKAN, you just use the usual tools and techniques to explore and hack the +CSS. + +.. todo:: Link to some tools? + + e.g. Firefox inspector etc (or Chrome? Firebug?) + + e.g. Some online CSS reference. + +Let's add a bit more code to our ``example_theme.css`` file. This CSS +implements a partial imitation of the `datahub.io