# Flask Edits
Tired of constant client requests to tweak that elusive snippet or image on your **/about** page?
Enter **Flask-Edits**. Simply mark sections of your templates with **{% editable %}**, and voilà, they're ready for modification in a sleek admin panel. Say goodbye to the hassle of copy adjustments.
![App Screenshot](https://raw.githubusercontent.com/MahirShah07/Flask_Edits/main/ReadMePhotos/Image1.png)
## Installation
```bash
pip install flask_edits
```
## Usage
```bash
from flask import Flask
from flask_edits import Edits
app = Flask(__name__)
edits = Edits(app)
```
All edits are neatly saved to disk as JSON. Configure your python file path to store them alongside your app for seamless version control.
```bash
from flask import Flask
from flask_edits import Edits
import os
app = Flask(__name__)
app.config['FILE_PATH'] = os.path.dirname(__file__)
edits = Edits(app)
```
## Edits Seaction
Edit any page with registered editable sections directly in the interface. Currently, only static HTML is supported, with Jinja2 support on the roadmap.
![App Screenshot](https://raw.githubusercontent.com/MahirShah07/Flask_Edits/main/ReadMePhotos/Image2.png)
The **Summernote HTML Editor** is included but not activated by default. Enable it with:
```bash
app.config['EDITS_SUMMERNOTE'] = True
```
* **Uploading Images/Videos**:
* Summernote enables users to upload images directly into the editor.
* Users can click on the "Insert Image"/"Insert Video" button, select an image/Video file, and upload it.
* After uploading, Summernote inserts the image/video into the content, allowing resizing and cropping.
* **Text Formatting**:
* Summernote offers a wide range of text formatting options.
* Users can change font style, size, and color, apply bold, italic, or underline styles.
* Additionally, users can create bulleted or numbered lists and align text as desired.
* **Advanced Features**:
* Summernote provides advanced text editing features like tables, code blocks, and LaTeX equations.
* Users can insert tables, format them, and add rows or columns.
* Furthermore, Summernote supports code blocks with syntax highlighting and LaTeX equations for mathematical expressions.
For Further information Visit [SUMMERNOTE's Webite](https://summernote.org/).
Now you can access all your edits from **/edits** (default) but to make it secure so that no one else could access it is advised to add a security system. There are two ways this can be done:
## Security
**Security Reminder**: Flask_Edits doesn't presume your authentication method by default. Protect the admin interface from following methods from developer.
* **Automatic Lock** (Reccomended): In flask_edits itself there is an **sqlalchamy** based login manager if you want to use that use the following code. There are few points to consider before using the method.
```bash
from flask import Flask
from flask_edits import Edits
import os
app = Flask(__name__)
app.secret_key = 'your_secret_key_here' #DO NOT SHARE THIS WITH ANYONE
app.config['FILE_PATH'] = os.path.dirname(__file__)
app.config['SQL_EDITS_LOCKED'] = True
app.config['EDITS_USERNAME'] = 'your_username'
app.config['EDITS_PASSWORD'] = 'your_password'
edits = Edits(app)
```
* **EDITS_USERNAME & EDITS_PASSWORD**
* **Remove EDITS_USERNAME & EDITS_PASSWORD**: After running the app for first time remove EDITS_USERNAME & EDITS_PASSWORD from congif as as soon as the app recives the EDITS_USERNAME & EDITS_PASSWORD it creates users and keeping USAMENAME and PASSSWORD in your file is not reecomended for deployment purposes.
* **Using only EDITS_USERNAME or EDITS_PASSWORD**: In the flask_edits there is a function where if only EDITS_USERNAME or only EDITS_PASSWORD is provided then your username and password will be same.
* **Few other Terms you could define:**
* **EDITS_URL**: It is the url where you will be able to access you dashbaord. Here is an example of how you could define it.
```bash
app.config['EDITS_URL'] = '/edits' #default: '/edits'
```
* **EDITS_ROUTE**: Edits route is where you could login to you editing page. Here is an example of how you could define it.
```bash
app.config['EDITS_ROUTE'] = '/login' #default: '/login'
```
* **EDITS_STATIC**: This config enables users to get folder view of their static folder even if you have changed the name of static folder it will access it. you could create folder, upload, rename, delete and unzip zipped files.
```bash
app.config['EDITS_STATIC'] = True #default: False
```
![App Screenshot](https://raw.githubusercontent.com/MahirShah07/Flask_Edits/main/ReadMePhotos/Image3.png)
* **EDITS_PREVIEW**: Preview mode, enabled by default, ensures edits remain hidden until ?preview=true is appended to the URL. Easily toggle preview mode in the admin panel for seamless pre-live editing. Turn on previews for production use.
```bash
app.config['EDITS_PREVIEW'] = False #default: True
```
![App Screenshot](https://raw.githubusercontent.com/MahirShah07/Flask_Edits/main/ReadMePhotos/Image4.png)
* **PERMANENT_SESSION_LIFETIME**: If session.permanent is true, the cookie’s expiration will be set this number of seconds in the future. Can either be a datetime.timedelta or an int. Flask’s default cookie implementation validates that the cryptographic signature is not older than this value.
```bash
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(minutes=60) #default: 60min
```
* **SQLALCHEMY_DATABASE_URI**: The database connection URI used for the default engine. It can be either a string or a SQLAlchemy URL instance. See below for example.
```bash
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///users.db' #default: sqlite:///users.db
```
* **SQLALCHEMY_TRACK_MODIFICATIONS**: If enabled, all insert, update, and delete operations on models are recorded, then sent in models_committed and before_models_committed signals when session.commit() is called.This adds a significant amount of overhead to every session. Prefer using SQLAlchemy’s ORM Events directly for the exact information you need.
```bash
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False #default: False
```
* **Manual Lock**: If you alredy have a user-managemnt system and want to add same to it then, we also have support that users too. Here is an example of cose of how you code should look like.
```bash
from flask import Flask
from flask_edits import Edits
import os
app = Flask(__name__)
app.config['FILE_PATH'] = os.path.dirname(__file__)
app.config['EDITS_LOCKED'] = True
app.config['EDITS_ROUTE'] = '/login'
#Mention your apps login route where you are loggin in users.
edits = Edits(app)
```
![Logo](https://raw.githubusercontent.com/MahirShah07/Flask_Edits/main/ReadMePhotos/logo.png)
## Resources
- [MDI Icons From pictogrammers](https://pictogrammers.github.io/@mdi/font/2.0.46/)
## Authors
- [@MahirShah07](https://www.mahirshah.dev)
## Support
For support, email mahir.shah.sd@gmail.com or join our contact me from my Website https://mahirshah.dev.
## Copyright 2024 Mahir Shah
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Raw data
{
"_id": null,
"home_page": "https://github.com/MahirShah07/",
"name": "editable-flask",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "editable_flask",
"author": "Mahir Shah",
"author_email": "mahir.shah.sd@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/58/63/5dc30a9b74fd0ea4e04b45608ff99dce708617c2355f806cae002a5678bb/editable_flask-0.0.1.tar.gz",
"platform": null,
"description": "\n# Flask Edits\n\nTired of constant client requests to tweak that elusive snippet or image on your **/about** page?\n\nEnter **Flask-Edits**. Simply mark sections of your templates with **{% editable %}**, and voil\u00e0, they're ready for modification in a sleek admin panel. Say goodbye to the hassle of copy adjustments.\n\n![App Screenshot](https://raw.githubusercontent.com/MahirShah07/Flask_Edits/main/ReadMePhotos/Image1.png)\n## Installation\n```bash\n pip install flask_edits\n```\n## Usage\n```bash\nfrom flask import Flask\nfrom flask_edits import Edits\n\napp = Flask(__name__)\nedits = Edits(app)\n\n```\nAll edits are neatly saved to disk as JSON. Configure your python file path to store them alongside your app for seamless version control.\n\n```bash\nfrom flask import Flask\nfrom flask_edits import Edits\nimport os\n\napp = Flask(__name__)\napp.config['FILE_PATH'] = os.path.dirname(__file__)\nedits = Edits(app)\n\n```\n\n## Edits Seaction\nEdit any page with registered editable sections directly in the interface. Currently, only static HTML is supported, with Jinja2 support on the roadmap.\n\n![App Screenshot](https://raw.githubusercontent.com/MahirShah07/Flask_Edits/main/ReadMePhotos/Image2.png)\n\nThe **Summernote HTML Editor** is included but not activated by default. Enable it with:\n```bash\napp.config['EDITS_SUMMERNOTE'] = True\n```\n* **Uploading Images/Videos**:\n * Summernote enables users to upload images directly into the editor.\n * Users can click on the \"Insert Image\"/\"Insert Video\" button, select an image/Video file, and upload it.\n * After uploading, Summernote inserts the image/video into the content, allowing resizing and cropping.\n* **Text Formatting**:\n * Summernote offers a wide range of text formatting options.\n * Users can change font style, size, and color, apply bold, italic, or underline styles.\n * Additionally, users can create bulleted or numbered lists and align text as desired.\n* **Advanced Features**:\n * Summernote provides advanced text editing features like tables, code blocks, and LaTeX equations.\n * Users can insert tables, format them, and add rows or columns.\n * Furthermore, Summernote supports code blocks with syntax highlighting and LaTeX equations for mathematical expressions.\nFor Further information Visit [SUMMERNOTE's Webite](https://summernote.org/).\n\nNow you can access all your edits from **/edits** (default) but to make it secure so that no one else could access it is advised to add a security system. There are two ways this can be done:\n\n## Security\n**Security Reminder**: Flask_Edits doesn't presume your authentication method by default. Protect the admin interface from following methods from developer.\n* **Automatic Lock** (Reccomended): In flask_edits itself there is an **sqlalchamy** based login manager if you want to use that use the following code. There are few points to consider before using the method.\n ```bash\n from flask import Flask\n from flask_edits import Edits\n import os\n\n app = Flask(__name__)\n app.secret_key = 'your_secret_key_here' #DO NOT SHARE THIS WITH ANYONE\n app.config['FILE_PATH'] = os.path.dirname(__file__)\n app.config['SQL_EDITS_LOCKED'] = True\n app.config['EDITS_USERNAME'] = 'your_username'\n app.config['EDITS_PASSWORD'] = 'your_password'\n edits = Edits(app)\n ```\n * **EDITS_USERNAME & EDITS_PASSWORD**\n * **Remove EDITS_USERNAME & EDITS_PASSWORD**: After running the app for first time remove EDITS_USERNAME & EDITS_PASSWORD from congif as as soon as the app recives the EDITS_USERNAME & EDITS_PASSWORD it creates users and keeping USAMENAME and PASSSWORD in your file is not reecomended for deployment purposes.\n * **Using only EDITS_USERNAME or EDITS_PASSWORD**: In the flask_edits there is a function where if only EDITS_USERNAME or only EDITS_PASSWORD is provided then your username and password will be same.\n * **Few other Terms you could define:**\n * **EDITS_URL**: It is the url where you will be able to access you dashbaord. Here is an example of how you could define it.\n ```bash\n app.config['EDITS_URL'] = '/edits' #default: '/edits'\n ```\n * **EDITS_ROUTE**: Edits route is where you could login to you editing page. Here is an example of how you could define it.\n ```bash\n app.config['EDITS_ROUTE'] = '/login' #default: '/login'\n ```\n * **EDITS_STATIC**: This config enables users to get folder view of their static folder even if you have changed the name of static folder it will access it. you could create folder, upload, rename, delete and unzip zipped files.\n ```bash\n app.config['EDITS_STATIC'] = True #default: False\n ```\n ![App Screenshot](https://raw.githubusercontent.com/MahirShah07/Flask_Edits/main/ReadMePhotos/Image3.png)\n * **EDITS_PREVIEW**: Preview mode, enabled by default, ensures edits remain hidden until ?preview=true is appended to the URL. Easily toggle preview mode in the admin panel for seamless pre-live editing. Turn on previews for production use.\n ```bash\n app.config['EDITS_PREVIEW'] = False #default: True\n ```\n ![App Screenshot](https://raw.githubusercontent.com/MahirShah07/Flask_Edits/main/ReadMePhotos/Image4.png)\n * **PERMANENT_SESSION_LIFETIME**: If session.permanent is true, the cookie\u2019s expiration will be set this number of seconds in the future. Can either be a datetime.timedelta or an int. Flask\u2019s default cookie implementation validates that the cryptographic signature is not older than this value.\n ```bash\n app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(minutes=60) #default: 60min\n ```\n * **SQLALCHEMY_DATABASE_URI**: The database connection URI used for the default engine. It can be either a string or a SQLAlchemy URL instance. See below for example.\n ```bash\n app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///users.db' #default: sqlite:///users.db\n ```\n * **SQLALCHEMY_TRACK_MODIFICATIONS**: If enabled, all insert, update, and delete operations on models are recorded, then sent in models_committed and before_models_committed signals when session.commit() is called.This adds a significant amount of overhead to every session. Prefer using SQLAlchemy\u2019s ORM Events directly for the exact information you need.\n ```bash\n app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False #default: False\n ```\n* **Manual Lock**: If you alredy have a user-managemnt system and want to add same to it then, we also have support that users too. Here is an example of cose of how you code should look like.\n ```bash\n from flask import Flask\n from flask_edits import Edits\n import os\n\n app = Flask(__name__)\n app.config['FILE_PATH'] = os.path.dirname(__file__)\n app.config['EDITS_LOCKED'] = True\n app.config['EDITS_ROUTE'] = '/login'\n #Mention your apps login route where you are loggin in users.\n edits = Edits(app)\n ```\n![Logo](https://raw.githubusercontent.com/MahirShah07/Flask_Edits/main/ReadMePhotos/logo.png)\n\n## Resources\n - [MDI Icons From pictogrammers](https://pictogrammers.github.io/@mdi/font/2.0.46/)\n\n## Authors\n- [@MahirShah07](https://www.mahirshah.dev)\n\n## Support\nFor support, email mahir.shah.sd@gmail.com or join our contact me from my Website https://mahirshah.dev.\n\n## Copyright 2024 Mahir Shah\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u201cSoftware\u201d), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \u201cAS IS\u201d, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Addon to Library named flask which helps to edit html content in running app",
"version": "0.0.1",
"project_urls": {
"Homepage": "https://github.com/MahirShah07/"
},
"split_keywords": [
"editable_flask"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "58635dc30a9b74fd0ea4e04b45608ff99dce708617c2355f806cae002a5678bb",
"md5": "49596cf58cef875fa350272d1c8921b8",
"sha256": "3f9f13dc30cead6f8c914505d672044884baa3f6ccd2766432dd9dd7874543d3"
},
"downloads": -1,
"filename": "editable_flask-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "49596cf58cef875fa350272d1c8921b8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 12396,
"upload_time": "2024-04-24T00:42:00",
"upload_time_iso_8601": "2024-04-24T00:42:00.926145Z",
"url": "https://files.pythonhosted.org/packages/58/63/5dc30a9b74fd0ea4e04b45608ff99dce708617c2355f806cae002a5678bb/editable_flask-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-24 00:42:00",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "editable-flask"
}