Giter VIP home page Giter VIP logo

ox-tagfilter-js's Introduction

Dynamic tag filtering in org-mode exported HTML documents

This JavaScript code adds dynamic tag filtering to HTML documents exported from Emacs Org-mode. It allows to hide/reveal page content based on tags and TODO-keywords, which may be useful for larger documents like journals, all-in-one notes files, etc. Of course, it will not be useful at all if you are not using any tags or TODO-keywords in your org files.

Author's use case: I have a growing journal of notes which is automatically published as HTML to a private web space. When looking back at stuff or looking for something specific, I find it useful to be able to filter the page to specific content (and hide the rest).

Screencast

Screencast

The CSS for the screencast document can be found here: https://sandyuraz.com/blogs/orgmode-css/

Usage

Include the script in exported HTML documents by adding the following Org-mode line to your org files:

#+HTML_HEAD_EXTRA: <script src="https://cdn.jsdelivr.net/gh/oyvindstegard/ox-tagfilter-js/ox-tagfilter.js"></script>

Alternatively you can set the org-mode variable org-html-head-extra and include the <script>.. tag there, or just include it anywhere in documents really.

You may also copy the ox-tagfilter.js file to your own hosting and change the URL as appropriate, if you dislike the dependency on jsdelivr.net.

If the HTML document has exported tags or TODO-keywords in it, you should see the values appear as buttons on the top. Click those to filter the content dynamically. Press the ESC key to clear all selected buttons and show all content.

As you filter the content, the set of available filters are reduced, so that you can avoid selecting combinations that match nothing.

Custom location of filter buttons in HTML document

If you don't like the default location of the filter buttons, this can be customized by inserting a placeholder <div>-tag anywhere you like in the exported HTML document. You can include it with an HTML export block such as:

#+BEGIN_EXPORT html
<div id='oxtf-filter-list'></div>
#+END_EXPORT

The filter buttons will replace that particular element, instead of being injected in the default location at the top of the document.

Demo (test documents)

The following HTML documents have been exported from test.org using Org mode with completely default configuration and only changing the doctype settings:

Compatibility

The script is compatible with the most common HTML doc-type flavours that Org-mode supports. This includes html5 (including "fancy" variant) and xhtml-strict.

In general, the JavaScript code only works in modern web browsers.

ox-tagfilter-js's People

Contributors

oyvindstegard avatar

Stargazers

Tianyu Chen avatar zeit avatar  avatar Weaver Marquez avatar a13ph avatar David Wright avatar DarkBuffalo avatar Em D avatar pixor avatar Adam Porter avatar Ihor Radchenko avatar

Watchers

James Cloos avatar  avatar Ihor Radchenko avatar

Forkers

alphapapa

ox-tagfilter-js's Issues

Searching outside current page (index/sitemap)

Hi,
Thanks again for implementing this!

AFAIU, the code currenly works only on current html page.
It would be great to add an ability to search across the whole website if index/sitemap are available.

WDYT?

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.