Giter VIP home page Giter VIP logo

ckanext-pages's Introduction

Tests

ckanext-pages

This extension gives you an easy way to add simple pages to CKAN.

By default you can add pages to the main CKAN menu.

Tested on CKAN 2.9 and 2.10.

Note: For CKAN 2.7 and 2.8 use v0.3.7 or older versions.

Installation

Use pip to install this plugin. This example installs it in /home/www-data/pyenv, assuming you have setup a virtualenv there:

source /home/www-data/pyenv/bin/activate
pip install -e 'git+https://github.com/ckan/ckanext-pages.git#egg=ckanext-pages'

Make sure to add pages to ckan.plugins in your config file:

ckan.plugins = pages

Database initialization

You need to initialize database from command line with the following commands:

ON CKAN >= 2.9:

(pyenv) $ ckan --config=/etc/ckan/default/ckan.ini db upgrade -p pages

Configuration

Extra config options allow you to control the creation of extra pages against groups and organizations.

To swich on this behaviour, to your config add:

ckanext.pages.organization = True
ckanext.pages.group = True

These options are False by default.

This module also gives you a quick way to remove default elements from the CKAN menu and you may need todo this in order for you to have space for the new items you add. These options are:

ckanext.pages.about_menu = False
ckanext.pages.group_menu = False
ckanext.pages.organization_menu = False

By default these are all set to True, like on a default install.

To enable HTML output for the pages (along with Markdown), add the following to your config:

ckanext.pages.allow_html = True

By default this option is set to False. Note that this feature is only available for CKAN >= 2.3. For older versions of CKAN, this option has no effect. Use this option with care and only allow this if you trust the input of your users.

If you want to use the WYSIWYG editor instead of Markdown:

ckanext.pages.editor = medium

or

ckanext.pages.editor = ckeditor

This enables either the medium or ckeditor

Extending ckanext-pages schema

This extension defines an IPagesSchema interface that allows other extensions to update the pages schema and add custom fields.

To do so, you can implement the method update_pages_schema in your extension:

import ckan.plugins as plugins
import ckan.plugins.toolkit as toolkit
from ckanext.pages.interfaces import IPagesSchema

class MyextPlugin(plugins.SingletonPlugin):
    plugins.implements(IPagesSchema)

    #IPagesSchema
    def update_pages_schema(self, schema):
        schema.update({
            'new_field': [
                toolkit.get_validator('not_empty'),
                toolkit.get_validator('boolean_validator')]
            })
        return schema

and also extends ckanext_pages/base_form.html and override the extra_pages_form block to add it to the form:

{% ckan_extends %}

{% set options = [{'value': True, 'text': _('Yes')}, {'value': False, 'text': _('No')}]%}
{% block extra_pages_form %}
    {{ form.select('new_field', id = 'new_field', label = 'New Field', options=options, selected=data.testing) }}
{% endblock extra_pages_form %}

If you want to override, make sure your extension is added before pages in the ckan.plugins config.

Extending the default CKEditor configuration

The default configuration used by the CKEditor widget is defined in the ckanext/pages/assets/js/ckedit.js file. This configuration can be overriden from your own plugin setting the window.ckan.pages.override_config variable. For example, create the following script in your extension:

```js
this.ckan = this.ckan || {};
this.ckan.pages = this.ckan.pages || {};

$(document).ready(function() {

  window.ckan.pages.override_config = {
      toolbarGroups: [
        //... your custom toolbar
      ],
      extraPlugins: '', // Add extra plugins here (make sure to also load their js/css assets from your plugin)
      // ...

  }

});
```

Configure your plugin assets to serve the script above, and extend the ckanext_pages/base_form.html template to add the asset to the ckanext-pages form page:

```
{% ckan_extends %}

{% asset 'my-plugin/pages-extra-config.js' %}

```

Dependencies

  • lxml (optional, only used for injecting resource views into pages)

License

Released under the GNU Affero General Public License (AGPL) v3.0. See the file LICENSE for details.

History

See the file CHANGELOG.md.

ckanext-pages's People

Contributors

amercader avatar carlqlange avatar deniszgonjanin avatar duskobogdanovski avatar joetsoi avatar johnmartin avatar jonathansberry avatar kindly avatar mattfullerton avatar metaodi avatar pdelboca avatar smotornyuk avatar smth avatar tino097 avatar tobes avatar torfsen avatar vitorbaptista avatar wardi avatar xingyz avatar zharktas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ckanext-pages's Issues

Server Error - An internal server error occurred

Any idea why your pages extension cause this https://gist.githubusercontent.com/wide-awake/e39b3b7ab9e006e43e83/raw/7ce8fc57b8287d2a905dbf560c7605fad0295ce4/error.log

I add pages successfully, and they looks alright as a list but when i open full URL i got "Server Error An internal server error occurred" and above is apache2 ckan_default.error.log

answer from Zharktas: that would be broken python code in file controller.py since it uses varibale lxml before it has a value.

Your package is broken ?

KeyError: 'resource'

I couldn’t find any help anywhere else. My apologies if my question seem silly.

I am using ckan ckan 2.5.3 with lxml installed.

I insert view iframes on a page, will get his error when the page runs
File '../ckanext-pages/ckanext/pages/controller.py', line 237 in _inject_views_into_page
package_id = context['resource'].resource_group.package_id
KeyError: 'resource'

apparently context is not added to the context

Has anyone seen this error before? Any ideas how to handle it?

Exception when saving page with empty body

Found in branch ckeditor-blog, commit 0498614

If you save a page with an empty body, we get the stack trace:

File '/usr/lib/ckan/default/src/ckan/ckanext/ckanext-pages/ckanext/pages/controller.py', line 266 in pages_show
  self._inject_views_into_page(_page)
File '/usr/lib/ckan/default/src/ckan/ckanext/ckanext-pages/ckanext/pages/controller.py', line 208 in _inject_views_into_page
  root = html.fromstring(_page['content'])
File '/usr/local/lib/python2.7/dist-packages/lxml-3.3.0beta1-py2.7-linux-x86_64.egg/lxml/html/__init__.py', line 704 in fromstring
  doc = document_fromstring(html, parser=parser, base_url=base_url, **kw)
File '/usr/local/lib/python2.7/dist-packages/lxml-3.3.0beta1-py2.7-linux-x86_64.egg/lxml/html/__init__.py', line 600 in document_fromstring
  value = etree.fromstring(html, parser, **kw)
File 'lxml.etree.pyx', line 3010 in lxml.etree.fromstring (src/lxml/lxml.etree.c:64046)
File 'parser.pxi', line 1700 in lxml.etree._parseMemoryDocument (src/lxml/lxml.etree.c:95363)
File 'parser.pxi', line 1571 in lxml.etree._parseDoc (src/lxml/lxml.etree.c:94102)
File 'parser.pxi', line 992 in lxml.etree._BaseParser._parseUnicodeDoc (src/lxml/lxml.etree.c:89871)
File 'parser.pxi', line 579 in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:85606)
File 'parser.pxi', line 680 in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:86732)
File 'parser.pxi', line 630 in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:86199)
XMLSyntaxError: None

The problem is at https://github.com/ckan/ckanext-pages/blob/ckeditor-blog/ckanext/pages/controller.py#L205

root = html.fromstring(_page['content'])

We can't pass an empty string to html.fromstring.

Add docs

Guise srsly...

Do I need to set up something? Where are the pages stored? How do I access the pages?

Update pages

Hi,

we are currently updating our ckan-version to 2.3.1. In this case we also have to update pages to the last version. However, we downloaded the last version and installed it via "python setup.py develop" (since there is no outgoing internet-connection on the remote server). Before the old folder was deleted and the new ckanext-pages-folder inserted.

But: How is it ensured that text of already customized pages is not lost?

Kind regards!

Localized URL results in incorrect page redirect.

When submitting a page with the WSGI editor and a localized URL (using the default patter, /{{lang}}) editing the page will submit successfully, but then redirect to /fr/fr/pages/<page>.

Using ckeditor, latest pages, and CKAN 2.6.

WYSIWYG editor Does not show up.

I have installed the ckanext-pages. By changing the configuration lines to false in plugin.py file I can get rid off About/Group/Organization menus as below.

def build_pages_nav_main(*args):

about_menu = p.toolkit.asbool(config.get('ckanext.pages.about_menu', False))
group_menu = p.toolkit.asbool(config.get('ckanext.pages.group_menu', False))
org_menu = p.toolkit.asbool(config.get('ckanext.pages.organization_menu', False))

However, I cannot get the WYSIWYG editor by changing the following.

def get_wysiwyg_editor():
return config.get('ckanext.pages.editor', 'ckeditor')

or

def get_wysiwyg_editor():
return config.get('ckanext.pages.editor', 'medium')

Language/Localisation of Article Content

It looks like the developers have been thinking a bit about the localisation of articles, as the db model has an unused "lang" field.

We're potentially interested in getting this up and running, if our clients decide this is important enough. We'd be happy to open it as a PR. I just wanted to touch base with the developers and hear a bit about why this work doesn't appear to have been finished. Were there any big problems you stumbled across? What approach were you planning to take?

Error 500 when creating View

Hello,

thank you for your extension. I've tried to import a view from a dataset catching the url of the view. When I put this link in my page, with ckeditor -> view, I've got next a error 500 Internal server.
It isn't possible to do that ?

Thank you very much for your answer !

Permission denied IO Error

Hello,
I installed pages plugin, but if i activate the plugin in the ini file i got this error:
IOError: [Errno 13] Permission denied: u'/usr/lib/ckan/default/src/ckan/ckan/public/base/i18n/de.js'
Owner of the file is user ckan and group is www-data but it doesnt work. So what I did wrong?

Insert HTML code

Hello, I'm thinking of a workflow that involves people adding embed codes in github pages, is that possible?
What should I manually patch to allow ckeditor to insert html directly?

Thanks.

Visibility status not kept on validation errors

Scenario, when creating a bog post:

  • Enter title
  • Skip over publish date (assuming it will auto fill to todays date)
  • Set to "Public"
  • Add content
  • Submit
  • Get error "Publish Date Must be supplied". Visibility has been set back to "Private" without me realising
  • (Ignore weird capitalisation and) fill in date
  • Submit
  • Done
  • Wonder why my post is not appearing where I expected it

Create *_index routes

We're using *_show routes with page='' as an index page route. Apart from being a bit confusing and not DRY (IMHO), I was unable to use h.build_nav_main to link to the blog's index, as I couldn't pass page='' to it.

I could've changed h.build_nav_main to allow passing parameters (and it might be a good idea in general) but, in this specific case, I think the correct fix is to add *_index routes.

The same pattern is used to create new pages. When using *_edit with page='', we go/create a new page.

@kindly What do you think? Is this pattern used in other places in CKAN? Looking quickly in ckan/config/routing.py, I found a few routes like group_index and group_new.

Unable to configure pages with a custom root_path

Hi,
I'm trying to use pages with our ckan platform which has been configured using the ckan.root_path as following (in the production.ini):

ckan.root_path = /catalog

And in the who.ini we have:

[plugin:friendlyform]
use = repoze.who.plugins.friendlyform:FriendlyFormPlugin
login_form_url= /catalog/user/login
login_handler_path = /login_generic
logout_handler_path = /user/logout
rememberer_name = auth_tkt
post_login_url = /catalog/user/logged_in
post_logout_url = /catalog/user/logged_out

while in nginx we have:

    location /catalog/ {
        proxy_pass http://localhost:8080/catalog/;
        proxy_set_header Host $host;
        proxy_cache_bypass $cookie_auth_tkt;
        proxy_no_cache $cookie_auth_tkt;
        proxy_cache_valid 30m;
        proxy_cache_key $host$scheme$proxy_host$request_uri;
    }

So ckan responds to:

http://XXXXXXXXX/catalog/

When we click on the icon on top to create a page it points to:

http://XXXXXXXXX/catalog/pages

When we create a page (f.e.: public so it will be published on the header of the page) the plugin points correctly to:

http://XXXXXXXXX/catalog/pages_edit

The problem is when we click on the new link created on the header the link bring us to:

http://XXXXXXXXX/pages/test

instead of:

http://XXXXXXXXX/catalog/pages/test

I've looked around but can't find any parameter to setup that path properly on the pages plugin.

Note: Still have to test grup and organization functionnalities.

Travis CI runs wrong CKAN versions

We have configured Travis to run our tests for different versions of CKAN, but it seems that this doesn't work as expected. For example, a recent run that was supposed to use CKAN 2.5 turned out to use 2.6 instead.

Include HTML?

How can I use regular HTML in the content area? Since the pages by default require sysadmin rights to create, it should be safe to accept HTML.

I found this, but not sure if it's usable: ckan/ckan#1747

Simplest fix I found was to change {{ h.render_markdown(c.page.content) }} to {{ c.page.content|safe }} in page.html ...Markdown doesn't work when doing that, but html does

Markdown features

Especially with this extension the usage of Markdown becomes more important, since we can now create separate pages with it, which is really useful. Unfortunately, not all Markdown features about embedding native HTML code work as described on the linked Markdown documentation. See CKAN issue #1332.

So, a more "advanced" way to insert content - either as Markdown or integrated into the CKAN template framework - would really help.

Error: 'module' object has no attribute 'pages/css/medium-editor.css'

I have installed this extension:

git clone https://github.com/ckan/ckanext-pages.git ckanext-pages.git
cd ckanext-pages.git
pip install -r dev-requirements.txt
python setup.py install

I have added to the config file of ckan this:

ckan.plugins = ... pages ...
ckanext.pages.allow_html = True
ckanext.pages.editor = ckeditor

I have started the server but I get the error:

File "/home/vagrant/ckan.git/local/lib/python2.7/site-packages/ckanext_pages-0.1-py2.7.egg/ckanext/pages/theme/templates_main/base.html", line 10, in block "links"
  {% resource 'pages/css/medium-editor.css' %}
File "/home/vagrant/ckan.git/ckan/lib/jinja_extensions.py", line 315, in _call
  h.include_resource(args[0], **kwargs)
File "/home/vagrant/ckan.git/ckan/lib/helpers.py", line 1358, in include_resource
  r = getattr(fanstatic_resources, resource)
AttributeError: 'module' object has no attribute 'pages/css/medium-editor.css'

Do I have to install the editor manually?

Extension does not work with SQLAlchemy 0.8 (needed for Ckan on Ubuntu 14.04)

For various reasons, SQLAlchemy 0.8 is needed to run CKAN 2.2 on Ubuntu 14.04. Unfortunately, it seems that the current code of ckanext-pages is not compatible with version 0.8.

The affected code (at least where it fails) is in db.py, L88:

    if isinstance(obj, sa.engine.base.RowProxy):
        fields = obj.keys()
    else:
        ModelClass = obj.__class__
        table = class_mapper(ModelClass).mapped_table
        fields = [field.name for field in table.c]

Error looks like:

File '/usr/lib/ckan/ckandev/src/ckanext-pages/ckanext/pages/db.py', line 88 in table_dictize
if isinstance(obj, sa.engine.base.RowProxy):
AttributeError: 'module' object has no attribute 'RowProxy'

It seems that RowProxy does not exist anymore in 0.8.

Crashes if unicode characters occur

How to reproduce:
Crate new page with unicode characters in a title e.g. "Otevřená města"
CKAN "2.7.0"

  extra_vars={'dataset_type': package_type})
File '/usr/lib/ckan/default/src/ckan/ckan/lib/base.py', line 177 in render
  return cached_template(template_name, render_template)
File '/usr/lib/ckan/default/lib/python2.7/site-packages/pylons/templating.py', line 249 in cached_template
  return render_func()
File '/usr/lib/ckan/default/src/ckan/ckan/lib/base.py', line 131 in render_template
  return render_jinja2(template_name, globs)
File '/usr/lib/ckan/default/src/ckan/ckan/lib/base.py', line 88 in render_jinja2
  return template.render(**extra_vars)
File '/usr/lib/ckan/default/lib/python2.7/site-packages/jinja2/environment.py', line 989 in render
  return self.environment.handle_exception(exc_info, True)
File '/usr/lib/ckan/default/lib/python2.7/site-packages/jinja2/environment.py', line 754 in handle_exception
  reraise(exc_type, exc_value, tb)
File '/usr/lib/ckan/default/src/ckan/ckan/templates/package/search.html', line 2 in top-level template code
  {% import 'macros/form.html' as form %}
File '/usr/lib/ckan/default/src/ckan/ckan/templates/page.html', line 1 in top-level template code
  {% extends "base.html" %}
File '/usr/lib/ckan/default/src/ckanext-pages/ckanext/pages/theme/templates_main/base.html', line 1 in top-level template code
  {% ckan_extends %}
File '/usr/lib/ckan/default/src/ckan/ckan/templates/base.html', line 103 in top-level template code
  {%- block page %}{% endblock -%}
File '/usr/lib/ckan/default/src/ckan/ckan/templates/page.html', line 14 in block "page"
  {%- block header %}
File '/usr/lib/ckan/default/src/ckan/ckan/templates/page.html', line 15 in block "header"
  {% include "header.html" %}
File '/usr/lib/ckan/default/src/ckanext-pages/ckanext/pages/theme/templates_main/header.html', line 1 in top-level template code
  {% ckan_extends %}
File '/usr/lib/ckan/default/src/ckan/ckan/templates/header.html', line 1 in top-level template code
  {% block header_wrapper %}
File '/usr/lib/ckan/default/src/ckan/ckan/templates/header.html', line 98 in block "header_wrapper"
  {% block header_site_navigation %}
File '/usr/lib/ckan/default/src/ckan/ckan/templates/header.html', line 101 in block "header_site_navigation"
  {% block header_site_navigation_tabs %}
File '/usr/lib/ckan/default/src/ckan/ckan/templates/header.html', line 102 in block "header_site_navigation_tabs"
  {{ h.build_nav_main(
File '/usr/lib/ckan/default/src/ckanext-pages/ckanext/pages/plugin.py', line 53 in build_pages_nav_main
  link = h.literal('<a href="/pages/%s">%s</a>' % (str(page['name']), str(page['title'])))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0159' in position 4: ordinal not in range(128)```

FontAwesome update on CKAN 2.7

CKAN 2.7 uses FontAwesome 4, and there are multiple changes from version 3.

For ckanext-pages, some of these have already been taken care of by #51, but it seems that there are still some things to fix. For example, we use the edit icon from FA 3, which is now called pencil-square-o. In particular, we need to check the ckan_icon arguments to map_connect and the icon arguments to the link_for template macro.

As with #51 we need to maintain backwards-compatibility with earlier versions of CKAN. This can be done by using both the new and old FA CSS classes (e.g. class="icon-edit fa fa-pencil-square-o") or by using a custom helper function. In the latter case, we should use one helper function for all icons (pages_get_icon) instead of adding a separate helper function for each icon.

Pages extension with CKAN 2.3

I have installed pages plugin in CKAN 2.3. It seems that all works fine but when you try to create a new page, it brokes and CKAN throws a 500 error. After that, if you go to the pages menu, you can see all the created pages but when you click on them it throws again the 500 error. Any idea? I have checked the log but it only points to something wrong in "ckanext.pages.controller:PagesController"

Thanks

Error 500 with ckan 2.5

Good morning,

I have an error in a ckan 2.5. When I click on the page icon I get a 500 error.

The error is:
File '/usr/lib/ckan/default/src/ckanext-pages/ckanext/pages/plugin.py', line 94 in get_plus_icon
   ckan_version = float (h.ckan_version () [0: 3])
AttributeError: 'module' object has no attribute 'ckan_version'

I think my ckan.lib.helpers does not have ckan_version()

This is my log file: logerrorpages.zip

Bye.

Items added to main navigation get multiplied when header_site_navigation_tabs is extended with super()

When using ckanext-pages with another CKAN extension that extends header.html, or the header_site_navigation_tabs block specifically, pages or blog posts added to the main navigation through the ckanext-pages UI, are shown once per super() call in the templates.

https://github.com/ckan/ckanext-pages/blob/master/ckanext/pages/plugin.py#L24

If header.html is extended three times in three separate extensions, each super() call will trigger the action for concatenating links in the navigation.

I already communicated this problem with @amercader and he recommended that I report it here.

AttributeError: 'module' object has no attribute 'link_to'

Hello
The first time I ran ckan with the plugin enabled the page edit functionality worked fine. When I added my first page the site responds with internal server error on any page containing the navigation menu. The log contained the following error "AttributeError: 'module' object has no attribute 'link_to'". The error occurs in line 45 in the plugin file: "link = h.link_to(page.get('title')". I am running ckan version 2.6.0a.
Any idea how to solve this?
Thank you

cannot find macros/form.html

the base_form.html in templates imports macros/form.html {% import 'macros/form.html' as form %} but cannot find the file in the macros folder. i basically want to make the date picker for publish a date input type. is there any other way to do this? other than modifing macros/form.html?

Feature suggest: pages on datasets

In addition to the features already supported by this awesome extension, I would be interested in having a page added for all datasets by default.

Sketch of the feature requirements:

  • Datasets currently have a description field. This field would support markdown and treated as the dataset's page source. This field's textbox would display using the editor (medium or ckeditor).
  • A new tab called 'info' (or something) would be added to the dataset template, and display the description content rendered according to the extension settings (supporting richer content than the standard ckan description field)
  • The info tab would allow content authors to provide more thorough documentation for the dataset.

I realize that half or more of this feature request is actually related to a custom theme. I'd be interested to hear any feedback about how this feature could be implemented using this extension out of the box. And, if other people would find that a useful addition to the core ckan.

No anonymous access in CKAN 2.2

Even though the last commit in master branch seems to handle the new auth methods in CKAN 2.2, the pages I have defined are not visible for not-logged in users any more after updating CKAN from 2.1.1 to 2.2. See example http://demo.offene-daten.me/pages/faq.

Is there anything else to be changed?

My auth settings:

ckan.auth.anon_create_dataset = false
ckan.auth.create_unowned_dataset = false
ckan.auth.create_dataset_if_not_in_organization = false
ckan.auth.user_create_groups = true
ckan.auth.user_create_organizations = false
ckan.auth.user_delete_groups = false
ckan.auth.user_delete_organizations = false
ckan.auth.create_user_via_api = false
ckan.auth.create_user_via_web = false

Pages settings:

ckanext.pages.about_menu = False
ckanext.pages.group_menu = True
ckanext.pages.organization_menu = False

Don't use lxml

Please

It's a pain to install and probably overkill for what the extension is trying to do

Optional sidebar

It would be useful if ckanext-pages allowed for a sidebar on each page created.

The sidebar should be turn-off-able (through a checkbox) and should allow for markdown input. Primary use-cases will be for:

  • Extra explanatory text
  • Building a small sub-menu for navigating through other pages.

I don't think either option requires that you should be able to build and store sidebars for sharing between pages (that's not very minimal).

CKAN 2.5a: db_init requires extend_existing=True

Reported also at ckan/ckan#2679 for reference.

Running into

...
(ckanext-pages gets called for the first time)
File '/project/ckanext-pages/ckanext/pages/actions.py', line 223 in pages_list
  return _pages_list(context, data_dict)
File '/project/ckanext-pages/ckanext/pages/actions.py', line 76 in _pages_list
  db.init_db(context['model'])
File '/project/ckanext-pages/ckanext/pages/db.py', line 112 in init_db
  sa.Column('extras', types.UnicodeText, default=u'{}'),
File '/usr/lib/ckan/local/lib/python2.7/site-packages/sqlalchemy/sql/schema.py', line 339 in __new__
  "existing Table object." % key)
InvalidRequestError: Table 'ckanext_pages' is already defined for this MetaData instance.  Specify 'extend_existing=True' to redefine options and columns on an existing Table object.

Can be fixed with adding "extend_existing" to ckanext-pages/ckanext/pages/db.py in function init_db() after the the sa.Columns as shown:

    pages_table = sa.Table('ckanext_pages', model.meta.metadata,
        sa.Column('id', types.UnicodeText, primary_key=True, default=make_uuid),
        sa.Column('title', types.UnicodeText, default=u''),
        sa.Column('name', types.UnicodeText, default=u''),
        sa.Column('content', types.UnicodeText, default=u''),
        sa.Column('lang', types.UnicodeText, default=u''),
        sa.Column('order', types.UnicodeText, default=u''),
        sa.Column('private',types.Boolean,default=True),
        sa.Column('group_id', types.UnicodeText, default=None),
        sa.Column('user_id', types.UnicodeText, default=u''),
        sa.Column('publish_date', types.DateTime),
        sa.Column('page_type', types.DateTime),
        sa.Column('created', types.DateTime, default=datetime.datetime.utcnow),
        sa.Column('modified', types.DateTime, default=datetime.datetime.utcnow),
        sa.Column('extras', types.UnicodeText, default=u'{}'),
        extend_existing=True
    )

followed by datacats install (if using datacats) or presumably a python setup.py install in a source install.

Seems to work, haven't run any tests though apart from making sure pages work in GUI.

"ckanext.pages.about_menu = False" does not remove About link from nav bar.

I'm using CKAN v2.8.2.

According to the docs,

This module also gives you a quick way to remove default elements from the CKAN menu and you may need todo this in order for you to have space for the new items you add. These options are:

ckanext.pages.about_menu = False
ckanext.pages.group_menu = False
ckanext.pages.organization_menu = False

These settings work for group and organization, but do not affect about.

It looks like this can be resolved in plugin.py line 32 by changing

new_args = []
    for arg in args:
        if arg[0] == 'about' and not about_menu:
            continue

to

new_args = []
    for arg in args:
        if arg[0] == 'home.about' and not about_menu:
            continue

"Internal Server Error" when enabling 'pages' plugin

Whenever I add the pages plugin to my CKAN configuration file after following the install instructions in the Readme for this repository, I can't load my home page anymore. I get an internal server error.

I am running my CKAN instance with docker-compose. I installed ckanext-pages with pip inside of the Python venv running in the CKAN docker container. Then I added pages to my ckan.plugins section of my configuration. This part of my configuration is below:

ckan.plugins = stats text_view image_view recline_view datapusher datastore pages

CKAN runs fine if I remove the pages plugin from my configuration, but as soon as I add it back in, I can't load my home page anymore.

These are the logs in my CKAN container when I access my home page:

Traceback (most recent call last):
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/lib/ckan/venv/src/ckan/ckan/views/home.py", line 64, in index
    return base.render(u'home/index.html', extra_vars={})
  File "/usr/lib/ckan/venv/src/ckan/ckan/lib/base.py", line 127, in render
    return flask_render_template(template_name, **extra_vars)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/templating.py", line 134, in render_template
    context, ctx.app)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/templating.py", line 116, in _render
    rv = template.render(context)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/jinja2/environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates/home/index.html", line 2, in top-level template code
    {% set homepage_style = ( g.homepage_style or '1' ) %}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates/page.html", line 1, in top-level template code
    {% extends "base.html" %}
  File "/usr/lib/ckan/venv/src/ckanext-pages/ckanext/pages/theme/templates_main/base.html", line 1, in top-level template code
    {% ckan_extends %}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates/base.html", line 101, in top-level template code
    {%- block page %}{% endblock -%}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates/page.html", line 14, in block "page"
    {%- block header %}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates/page.html", line 15, in block "header"
    {% include "header.html" %}
  File "/usr/lib/ckan/venv/src/ckanext-pages/ckanext/pages/theme/templates_main/header.html", line 1, in top-level template code
    {% ckan_extends %}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates/header.html", line 1, in top-level template code
    {% block header_wrapper %} {% block header_account %}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates/header.html", line 84, in block "header_wrapper"
    {% block header_site_navigation %}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates/header.html", line 87, in block "header_site_navigation"
    {% block header_site_navigation_tabs %} {{ h.build_nav_main( ('search', _('Datasets')), ('organizations_index', _('Organizations')),
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates/header.html", line 87, in block "header_site_navigation_tabs"
    {% block header_site_navigation_tabs %} {{ h.build_nav_main( ('search', _('Datasets')), ('organizations_index', _('Organizations')),
  File "/usr/lib/ckan/venv/src/ckanext-pages/ckanext/pages/plugin.py", line 47, in build_pages_nav_main
    if (toolkit.c.action in ('pages_show', 'blog_show')
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/werkzeug/local.py", line 347, in __getattr__
    return getattr(self._get_current_object(), name)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/werkzeug/local.py", line 347, in __getattr__
    return getattr(self._get_current_object(), name)
  File "/usr/lib/ckan/venv/src/ckan/ckan/config/middleware/flask_app.py", line 334, in __getattr__
    return getattr(app_globals.app_globals, name)
AttributeError: '_Globals' object has no attribute 'action'
Traceback (most recent call last):
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/httpserver.py", line 1068, in process_request_in_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 655, in __init__
    self.handle()
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/httpserver.py", line 442, in handle
    BaseHTTPRequestHandler.handle(self)
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/httpserver.py", line 437, in handle_one_request
    self.wsgi_execute()
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/httpserver.py", line 287, in wsgi_execute
    self.wsgi_start_response)
  File "/usr/lib/ckan/venv/src/ckan/ckan/config/middleware/__init__.py", line 202, in __call__
    return self.apps[app_name](environ, start_response)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/repoze/who/middleware.py", line 86, in __call__
    app_iter = app(environ, wrapper.wrap_start_response)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/fanstatic/publisher.py", line 234, in __call__
    return request.get_response(self.app)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/request.py", line 1053, in get_response
    application, catch_exc_info=False)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/request.py", line 1022, in call_application
    app_iter = application(self.environ, start_response)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/fanstatic/injector.py", line 54, in __call__
    response = request.get_response(self.app)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/request.py", line 1053, in get_response
    application, catch_exc_info=False)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/request.py", line 1022, in call_application
    app_iter = application(self.environ, start_response)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1997, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/beaker/middleware.py", line 156, in __call__
    return self.wrap_app(environ, session_start_response)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1547, in handle_exception
    return self.finalize_request(handler(e), from_error_handler=True)
  File "/usr/lib/ckan/venv/src/ckan/ckan/config/middleware/flask_app.py", line 411, in error_handler
    extra_vars = {u'code': e.code, u'content': e.description}
AttributeError: 'exceptions.AttributeError' object has no attribute 'code'

Does anyone know what could be going wrong here? I am running the latest version of CKAN (as of the date of this post). Any help would be appreciated.

`Delete` does not work for organization and group pages

Steps to reproduce:

  1. Create a page for a group or organization
  2. Go to the edit view for that page (e.g., /group/pages_edit/test-group/test-group-page)
  3. Click Delete
  4. Click Confirm
  5. The main view for that page will reload (e.g., /group/pages/test-group/test-group-page and it will not be deleted

It seems like there are two issues:

  1. The delete URL generated for the Delete button (for both organization and group pages) is incorrect
  2. The method for deleting a group page is missing

Support iframe embeds

A really common use case is to embed videos, visualizations, etc from external sites

Can context['model'] be shared between threads?

I'm trying to determine whether ckanext-pages is responsible for a race condition that brought down our application last night. I'm wondering if you can help me figure out how to interpret the context['model'] object to see if it's possible that it could have been shared between two threads. Specifically, I'm interested in this code block:

def _pages_list(context, data_dict):
search = {}
if db.pages_table is None:
db.init_db(context['model'])

What would you expect context['model'] to represent in this case? It looks like db.py modifies in a number of different ways, including setting table mappings:

global pages_table
pages_table = sa.Table('ckanext_pages', model.meta.metadata,
sa.Column('id', types.UnicodeText, primary_key=True, default=make_uuid),
sa.Column('title', types.UnicodeText, default=u''),
sa.Column('name', types.UnicodeText, default=u''),
sa.Column('content', types.UnicodeText, default=u''),
sa.Column('lang', types.UnicodeText, default=u''),
sa.Column('order', types.UnicodeText, default=u''),
sa.Column('private',types.Boolean,default=True),
sa.Column('group_id', types.UnicodeText, default=None),
sa.Column('user_id', types.UnicodeText, default=u''),
sa.Column('publish_date', types.DateTime),
sa.Column('page_type', types.DateTime),
sa.Column('created', types.DateTime, default=datetime.datetime.utcnow),
sa.Column('modified', types.DateTime, default=datetime.datetime.utcnow),
sa.Column('extras', types.UnicodeText, default=u'{}'),
extend_existing=True
)
model.meta.mapper(
Page,
pages_table,
)

This was the block of code that caused my errors in question, so any guidance you might have to shed light on what's supposed to happen with the model object would be helpful. If you're interested in deeper context, you can see a more detailed investigation into our outage here: opendataphilly/opendataphilly-ckan#92 (comment)

pages URLs incorrect if a non default language selected

Steps to reproduce:

  1. install and enable ckanext-pages
  2. Explicitly select a language from the ckan footer
  3. login a sysadmin and add a page --> 404

Please advise if this is a configuration issue. Currently we consider this a bug.

Thanks, René

Problematic Inline Styles

When adding an image to a page, using the CKEditor interface, it is given inline width and height styles. This is problematic because (amongst other reasons) it conflicts with the max-width specified in the (Bootstrap) stylesheet. So if an image is added which is too wide for the page, it is (helpfully) scaled to fit, but then distorted by the inline fixed height.

Create properly versioned releases

Currently ckanext-pages doesn't have any releases, in fact it doesn't have any git tags at all. That makes it hard to pin a certain version of ckanext-pages as a dependency in automated CKAN installations. I could pin a certain commit, but that doesn't really tell me much half a year later -- I'd have to manually inspect all new commits to see what has changed.

Therefore, please start creating releases and version them via semantic versioning.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.