Package: wagtailsystemtext
Wagtail System TextThis is a library that enables cms editors to update static test in
Wagtail. By using identifiers developers mark the strings that can be
updated by the editor/moderator from the cms.A template identifier can look like this{% systemtext "title" %}.
When this identifier are evaluated it will be added to the cms under the
sectionSettings / System Textunder the nametitle. The entry
has a field calledstringthat can be updated, this is the text that
will be rendered to the website users.Identifiers can also be grouped, by using the group argument{% systemtext "title" group "headlines" %}we can make management
easier, identifiers without group will be assigned to thegeneralgroup.By default identifiers will added in lazy mode, so for instance when a
site renders a idenifier it will be added to that sites set of
identifiers. The are also management commands that both searches through
your code base and finds suiteable identifiers
(find_and_add_systemtext), syncs then betweeen sites
(sync_systemtext) and manual add/delete commands (add_systemtext/delete_systemtext).RequirementsPython 2.7Django 1.8+Wagtail 1.7+InstallationInstall the library with pip:$pipinstallwagtailsystemtextQuick SetupMake surewagtail.contrib.modeladminandwagtailsystemtextis
added to yourINSTALLED_APPS.INSTALLED_APPS=(# ...'wagtail.contrib.modeladmin','wagtailsystemtext',)Then add SiteSystemTextMiddleware to your middlewares, make sure you add
it afterwagtail.wagtailcore.middleware.SiteMiddlewareMIDDLEWARE_CLASSES=(# ...'wagtail.wagtailcore.middleware.SiteMiddleware','wagtailsystemtext.middlewares.SiteSystemTextMiddleware',)Done!UsageOverall the implementation follows the same convention of django
translations.StringsThis is how you work with regular text, supply identifer and group and
retrive the systemtext string.fromwagtailsystemtext.utilsimportsystemtextas_st_st('my_text')_st('main_label',group='buttons')_st('main_label',group='buttons',default='My label')Lazy stringsLazy strings are run when called upon, when for instance you want to
initialize a systemtext retrival before the middleware has run. Like in
a admin interface.fromwagtailsystemtext.utilsimportsystemtext_lazyas_st_st('my_text')_st('main_label',group='buttons')_st('main_label',group='buttons',default='My label')TemplatesSystemtext contains a templatetag called systemtext, that behaves in the
same way as Djangos{%trans...%}Templatetags{%loadsystemtext%}{%systemtext"my_text"%}{%systemtext"main_label"group"buttons"%}{%systemtext"main_label"group"buttons"default"My label"%}Management commandsfind_and_add_systemtext: Finds the systemtext identifiers in your
applications (by looking for_stand{% systemtext ... %})
and adds them to each wagtail site).add_systemtext: Add identifier to site(s)delete_systemtext: Remove identifiers from site(s)sync_systemtext: Sync identifiers between sites to make sure they
contain the samelist_systemtext: List all active systemtextSettingsSYSTEMTEXT_CACHE_PREFIX: Cache prefix ("wagtailsystemtext"by
default)SYSTEMTEXT_CACHE_EXPIRY: Cache expiry in seconds (10 min by
default)SYSTEMTEXT_REBUILD_ON_SAVE: If cache should be rebuilt on save
(Trueby default)SYSTEMTEXT_USE_DEFAULT_ON_EMPTY: If present, use default value
when string is empty (Falseby default)Release startThese hooks will automatically bump the application version when usinggit flow release ...chmod+x$PWD/git-hooks/bump-version.shln-nfs$PWD/git-hooks/bump-version.sh.git/hooks/post-flow-release-startln-nfs$PWD/git-hooks/bump-version.sh.git/hooks/post-flow-hotfix-startRoadmap[x]transtemplate tag support[x] Wagtail admin view with site permissions[x] Cache-rebild on save through admin[x] Default text support (on declaration)[x] Lazy text transforms[x] Add setting for fallbacking to default if string is empty[x] Automatic tag discovery[x] Sync command between sites[ ] Group filter in Wagtail admin[ ] Last accessed timestamps[ ]blocktranstemplate tag supportContributingWant to contribute? Awesome. Just send a pull request.LicenseWagtail System Text is released under theMIT
License.