Giter Site home page Giter Site logo

flask-edits's Introduction

Flask-Edits

"Can't you just, rewrite it to sound more edgy?"

Clients blowing up your phone to change some copy on the /about page?

Enter Flask-Edits. Mark sections of your templates as {% editable %} and their content is exposed in a slick admin panel. Never worry about tweaking copy again.

Screenshot

Usage

from flask.ext.edits import Edits

app = Flask(__name__)
edits = Edits(app)

All edits are saved to the disk as JSON, so configure a path to save the edits. Edits can be commited to version control along with the rest of the app.

import os.path as op
app.config['EDITS_PATH'] = op.join(op.dirname(op.abspath(__file__)), 'edits.json')

Mark sections of your Jinja templates as editable.

{% editable %}
Python is a programming language that lets you work quickly and integrate systems more effectively.
{% endeditable %}

Visit the URL that renders the template to register the editable section. It will not show up in the admin panel if you don't load the page first.

Admin

The Flask-Edits admin view is exposed by default at /edits. This can be changed in the configuration:

app.config['EDITS_URL'] = '/edits'

Note on security:

Like Flask-Admin, Flask-Edits does not make any assumptions about the authentication system you might be using. So, by default, the admin interface is completely open. Protect it behind basic auth or another form of authentication.

Editing

All pages that have registered editable sections are available to edit in the interface. At this time, only static HTML is supported. Support for Jinja2 is on the roadmap.

The Summernote HTML editor is included but not used by default. To enable it:

app.config['EDITS_SUMMERNOTE'] = True

When content is saved it instantly updates the Jinja context and writes to the JSON file on the server.

Each editable section is stored using the hash of it's original content. Therefore, if you have multiple sections with the same content, it will only appear once in the admin panel, but changing it will change all sections.

Clearing a section will revert it to the original content in the template.

Beware

Changing an editable section in a template file changes it's hash. You'll have to re-register the section and add the edits again.

Roadmap

  • Automatically register editable sections
  • Jinja2 content with context evaluation
  • Named sections
  • Preview edits
  • Multiple database backends
  • In-place page editing

flask-edits's People

Contributors

nathancahill avatar

Watchers

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