Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

codeborne/play-cms

 
 

Repository files navigation

A simple CMS for Play! applications

Ever had the requirement to quickly do a simple textual change to one of the static pages of your app? – Here comes the solution: Embed a simple CMS!

  • Create static pages with editable content
  • Declare parts of dynamic pages to be editable via the CMS
  • Use tinymce with an image uploader to edit pages and fragments!

To dig deeper into this module, take a look at documentation/manual/home.textile.

Quickstart

Add the dependency in dependency.yml


        require
                - play-cms -> cms 2.0
        repositories:
                - play-cms:
                  type: http
                  artifact: http://repo.codeborne.com/play-cms/[module]-[revision].zip
                  contains:
                          - play-cms -> *

Add routes:

GET   /page     module:cms

Of course only connected users can edit pages, and (by default) they must have the admin profile, so check against that profile in your controllers.Security.java, e.g.:

        static boolean check(String profile) {
                String username = connected();
                if (username == null)
                        return false;
                User user = User.findByName(username);
                if (user == null)
                        return false;
                if ("admin".equals(profile))
                        return user.admin;
                return false;
        }

You can change the required cms profile by adding a configuration property named cms.profile.

Now navigate to /page/admin and create and edit pages using the Tiny MCE HTML editor. After your have created a page of name, say, page1, eventually use the following URL to display it: /page/page1.

Optionally create the following templates to make the pages look more like being part of your app:

  • cms/default.html, which will be used to render your pages.
  • cms/cms.html, which will be used to render the cms admin pages.

Congratulations! You just added a CMS to your Play! App!

You could also use this CMS to edit parts of your pages. Simply put parts, say the footer, of your template into a cms display tag:


	<div id="footer">
		#{cms.display 'footer'}
		<a href="/page/terms.html">Terms</a>
		#{/cms.display}


After having rendered the changed template once, there exists a CMS page ‘footer’. Since this page is not active, you will not notice any differences in your app – yet! But if you start editing the new page and activate it, its content will be displayed instead of the content from your template.

Simple remove the page or inactivate it to re-establish the old content.

About

A simple CMS to be able to edit pages, page fragments and images using a WYSIWYG editor

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 83.8%
  • Java 8.4%
  • HTML 6.8%
  • Other 1.0%