Git Product home page Git Product logo

play-cms's Introduction

A simple CMS for Play! applications

Build Status

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 1.0

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}
</div>

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.

play-cms's People

Contributors

joergviola avatar michal-lipski avatar angryziber avatar

Watchers

 avatar James Cloos 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.