Git Product home page Git Product logo

help-tokens's Introduction

help-tokens

Django app for linking to help pages with short tokens.

PyPI Travis Codecov Supported Python versions License

Overview

There are various factors that affect what help page an application should link to:

  • There may be a number of relevant books
  • The version of the application might affect which book to display
  • The application's language might affect which book to display

This small Django app provides a means to use "help tokens" on the application pages, and then use those tokens, and various other settings, to determine the actual URL to use.

Documentation

Help-tokens provides a context processor, and a redirection URL. Configuration is in a number of settings.

Settings

Help-tokens reads these Django settings to create URLs:

  • HELP_TOKENS_INI_FILE: Path to a .ini file containing help token definitions. The format of the ini file is described below.
  • HELP_TOKENS_BOOKS: a dictionary mapping book slugs to URLs. For example:

    HELP_TOKENS_BOOKS = {
        'learner': 'http://edx.readthedocs.io/projects/learner-guide',
        'course_author': 'http://edx.readthedocs.io/projects/running-a-course',
    }
  • HELP_TOKENS_VERSION: a string used as part of the final URL, to choose the correct version of the book. For example, "latest".
  • HELP_TOKENS_LANGUAGE_CODE: the language code to use as part of the book URL, mapped through the [locales] section of the ini file.

INI file format

The .ini file pointed to by HELP_TOKENS_INI_FILE contains the definitions of the help tokens themselves.

The [pages] section defines the help tokens. Each help token definition consists of a book slug (defined in HELP_TOKENS_BOOKS), a colon, and a URL path. The default token is used for missing tokens. For example:

[pages]
default = learner:index.html
instructor = learner:SFD_instructor_dash_help.html
course = learner:index.html

cohortmanual = course_author:course_features/cohorts/cohort_config.html#assign-learners-to-cohorts-manually
cohortautomatic = course_author:course_features/cohorts/cohorts_overview.html#all-automated-assignment

The [locales] section defines language codes, used with HELP_TOKENS_LANGUAGE_CODE to determine the language portion of the URL:

[locales]
default = en
en = en
en_us = en

Context processor

The context processor is "help_tokens.context_processor". It adds a function get_online_help_info. Call it with a help token, and it will return a dict with a doc_url entry, the help URL. You can use it like this in a template:

<a href="${get_online_help_info('visibility')['doc_url']}">...</a>

This interface is a bit verbose, but is to maintain backward compatibility with a previous implementation of this context processor.

Redirection view

The help_tokens.urls URLs define a view that redirects to a help URL. You can include it in your app:

# For redirecting to help pages.
url(r'^help_token/', include('help_tokens.urls')),

Then visiting help_token/foobar will redirect to the URL defined by the "foobar" help token.

License

The code in this repository is licensed under the AGPL 3.0 unless otherwise noted. Please see LICENSE.txt for details.

How To Contribute

Contributions are very welcome.

Please read How To Contribute for details.

Even though they were written with edx-platform in mind, the guidelines should be followed for Open edX code in general.

PR description template should be automatically applied if you are sending PR from GitHub interface; otherwise you can find it it at PULL_REQUEST_TEMPLATE.md

Issue report template should be automatically applied if you are sending it from GitHub UI as well; otherwise you can find it at ISSUE_TEMPLATE.md

Reporting Security Issues

Please do not report security issues in public. Please email [email protected].

Getting Help

Have a question about this repository, or about Open edX in general? Please refer to this list of resources if you need any assistance.

help-tokens's People

Contributors

nedbat avatar iamsobanjaved avatar dawoudsheraz avatar usamasadiq avatar mraarif avatar ayub-khan avatar bmedx avatar feanil avatar timmc-edx avatar edx-requirements-bot avatar ovidioreyna avatar

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.