Skip to main content
Help the Python Software Foundation raise $60,000 USD by December 31st!  Building the PSF Q4 Fundraiser

Editable text for PSU Django apps

Project description

PSU-Infotext

Reusable Django app specifically for PSU's custom-built web applications.
Provides the ability to include user-editable text in any site using the psu_base plugin.
Includes:

  • Template tags for editable text
  • WYSIWYG interface for editing the text

Quick Start

Dependencies

The following dependency is REQUIRED and must be installed in your app:

Installation

pip install psu-infotext

Configuration

  1. Configure psu-base in your Django app
  2. Add PSU-Infotext to your INSTALLED_APPS in settings.py:
    INSTALLED_APPS = [
       ...
       'psu_base',
       'psu_infotext',
    ]
    
  3. Configure your app's top-level urls.py to include Infotext views:
    urlpatterns = [
        ...
        path('infotext/', include(('psu_infotext.urls', 'psu_infotext'), namespace='infotext')),
    ]
    
  4. Run migrations: python manage.py migrate

Usage

Template Tags

The primary purpose of this app is to provide template tags that allow authorized users to update text on your site. For a small amount of text, use the {%infotext%} tag. For a larger amount of text, use the {%infotext_block%} tag.
The following example uses both tags:

{% load infotext_taglib %}

<h1>{%infotext code="main_heading" alt="Hello, World!"%}</h1>

{%infotext_block code="example_content"%}
<p>
    This is an example of longer <em>infotext</em><br>
    <ul>
        <li>Bla bla bla</li>
        <li>...</li>
    </ul>
</p>
{%end_infotext_block%}

Required Attributes:

  • code: This should uniquely identify the text for the page (url/path)
  • alt: Alternate (default) text to use when not found in the database
    (This only applies to the {%infotext%} tag. The body of the {%infotext_block%} tag is used as the alt text)

Optional Attributes:

  • auto_prefix: Defaults to True. When true, the text will be made specific to the page by prepending the request path (url) to the code attribute. Set this to False for any text that is to be displayed on multiple pages (like an error message) to prevent multiple instances of the text that may get out-of-sync and display differently on different pages.
  • replacements: This may be a dict, or string representation of a dict, with the key being the text to search for, and the value being the replacement text.

Additional documentation exists in Confluence.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for psu-infotext, version 0.8.1
Filename, size File type Python version Upload date Hashes
Filename, size psu_infotext-0.8.1-py2.py3-none-any.whl (20.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size psu-infotext-0.8.1.tar.gz (10.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page