Skip to content

Commit

Permalink
Merge pull request #1 from okfn/various-improvements
Browse files Browse the repository at this point in the history
Various improvements
  • Loading branch information
amercader authored Mar 14, 2018
2 parents 9e18eec + aab2071 commit a802458
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 152 deletions.
155 changes: 15 additions & 140 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,49 +1,29 @@
.. You should enable this project on travis-ci.org and coveralls.io to make
these badges work. The necessary Travis and Coverage config files have been
generated for you.

.. image:: https://travis-ci.org/okfn/ckanext-facetcollapse.svg?branch=master
:target: https://travis-ci.org/okfn/ckanext-facetcollapse

.. image:: https://coveralls.io/repos/okfn/ckanext-facetcollapse/badge.svg
:target: https://coveralls.io/r/okfn/ckanext-facetcollapse

.. image:: https://pypip.in/download/ckanext-facetcollapse/badge.svg
:target: https://pypi.python.org/pypi//ckanext-facetcollapse/
:alt: Downloads
=====================
ckanext-facetcollapse
=====================

.. image:: https://pypip.in/version/ckanext-facetcollapse/badge.svg
:target: https://pypi.python.org/pypi/ckanext-facetcollapse/
:alt: Latest Version
This extension makes the search facets collapsible.

.. image:: https://pypip.in/py_versions/ckanext-facetcollapse/badge.svg
:target: https://pypi.python.org/pypi/ckanext-facetcollapse/
:alt: Supported Python versions
.. image:: https://i.imgur.com/lTn4bZB.png

.. image:: https://pypip.in/status/ckanext-facetcollapse/badge.svg
:target: https://pypi.python.org/pypi/ckanext-facetcollapse/
:alt: Development Status

.. image:: https://pypip.in/license/ckanext-facetcollapse/badge.svg
:target: https://pypi.python.org/pypi/ckanext-facetcollapse/
:alt: License
There are four available default states, which can be set via the ``ckanext.facetcollpase.default`` configuration option:

=============
ckanext-facetcollapse
=============
- Collapse all: ``collapse`` (This is the default value)
- Collapse all but first: ``expand-first``
- Collapse empty: ``expand-navs``
- Collapse none: ``expand-all``

This extension makes the search facets collapsible. There are four available default states (configured in the admin panel):
This settings can also be modified via the `Administrator Interface <http://docs.ckan.org/en/latest/sysadmin-guide.html#customizing-look-and-feel>`_:

- `Collapse all`
- `Collapse all but first`
- `Collapse empty`
- `Collapse none`
.. image:: https://i.imgur.com/CB4BkTy.png

Some classes are added to each module, in case further styling is desirable:

- `expanded`
- `collapsed`
- `nothing-to-reveal` (when no facets match the search)
- ``expanded``
- ``collapsed``
- ``nothing-to-reveal`` (when no facets match the search)


------------
Expand All @@ -57,114 +37,9 @@ This extension assumes that JQuery and Bootstrap are included (as they are by de
Installation
------------

.. Add any additional install steps to the list below.
For example installing any non-Python dependencies or adding any required
config settings.
To install ckanext-facetcollapse:

1. Activate your CKAN virtual environment, for example::

. /usr/lib/ckan/default/bin/activate

2. Install the ckanext-facetcollapse Python package into your virtual environment::

pip install ckanext-facetcollapse

3. Add ``facetcollapse`` to the ``ckan.plugins`` setting in your CKAN
config file (by default the config file is located at
``/etc/ckan/default/production.ini``).

4. Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu::

sudo service apache2 reload


---------------
Config Settings
---------------

Configure the default state via the `Facet default` select, found on the `ckan-admin/config` page.


------------------------
Development Installation
------------------------

To install ckanext-facetcollapse for development, activate your CKAN virtualenv and
do::

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


.. -----------------
Running the Tests
-----------------
To run the tests, do::
nosetests --nologcapture --with-pylons=test.ini
To run the tests and produce a coverage report, first make sure you have
coverage installed in your virtualenv (``pip install coverage``) then run::
nosetests --nologcapture --with-pylons=test.ini --with-coverage --cover-package=ckanext.facetcollapse --cover-inclusive --cover-erase --cover-tests
---------------------------------
Registering ckanext-facetcollapse on PyPI
---------------------------------
ckanext-facetcollapse should be availabe on PyPI as
https://pypi.python.org/pypi/ckanext-facetcollapse. If that link doesn't work, then
you can register the project on PyPI for the first time by following these
steps:
1. Create a source distribution of the project::
python setup.py sdist
2. Register the project::
python setup.py register
3. Upload the source distribution to PyPI::
python setup.py sdist upload
4. Tag the first release of the project on GitHub with the version number from
the ``setup.py`` file. For example if the version number in ``setup.py`` is
0.0.1 then do::
git tag 0.0.1
git push --tags
----------------------------------------
Releasing a New Version of ckanext-facetcollapse
----------------------------------------
ckanext-facetcollapse is availabe on PyPI as https://pypi.python.org/pypi/ckanext-facetcollapse.
To publish a new version to PyPI follow these steps:
1. Update the version number in the ``setup.py`` file.
See `PEP 440 <http://legacy.python.org/dev/peps/pep-0440/#public-version-identifiers>`_
for how to choose version numbers.
2. Create a source distribution of the new version::
python setup.py sdist
3. Upload the source distribution to PyPI::
python setup.py sdist upload
4. Tag the new release of the project on GitHub with the version number from
the ``setup.py`` file. For example if the version number in ``setup.py`` is
0.0.2 then do::
git tag 0.0.2
git push --tags
2 changes: 1 addition & 1 deletion ckanext/facetcollapse/fanstatic/facetcollapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ $( document ).ready(function() {

// wrap the collapsible elements
$(".secondary .filters nav").each(function(){
$(this).next(".module-footer").andSelf().wrapAll("<div class='collapse' />");
$(this).next(".module-footer").addBack().wrapAll("<div class='collapse' />");
});

$(".secondary .filters .empty").wrap("<div class='collapse' />").closest(".module").addClass("nothing-to-reveal");
Expand Down
8 changes: 3 additions & 5 deletions ckanext/facetcollapse/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import ckan.plugins.toolkit as toolkit

from six import text_type
from ckan.plugins.toolkit import config


def facetcollapse_default():
'''facetcollapse helper function.'''

return config['ckanext.facetcollapse.default']
return toolkit.config.get('ckanext.facetcollapse.default', 'collapse')


class FacetcollapsePlugin(plugins.SingletonPlugin):
Expand All @@ -21,11 +21,9 @@ def update_config(self, config_):
toolkit.add_public_directory(config_, 'public')
toolkit.add_resource('fanstatic', 'facetcollapse')


def get_helpers(self):
return {'facetcollapse_default': facetcollapse_default}


def update_config_schema(self, schema):

ignore_missing = toolkit.get_validator('ignore_missing')
Expand All @@ -34,7 +32,7 @@ def update_config_schema(self, schema):

# This is a custom configuration option
'ckanext.facetcollapse.default': [ignore_missing,
text_type],
text_type],
})

return schema
6 changes: 0 additions & 6 deletions ckanext/facetcollapse/templates/base.html

This file was deleted.

3 changes: 3 additions & 0 deletions ckanext/facetcollapse/templates/package/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@
</div>
<a class="close no-text hide-filters"><i class="fa fa-times-circle"></i><span class="text">close</span></a>
</div>

{% resource 'facetcollapse/facetcollapse.js' %}

{% endblock %}

0 comments on commit a802458

Please sign in to comment.