Skip to content

Commit

Permalink
Merge pull request #5 from zhenyong97/FIX-#4
Browse files Browse the repository at this point in the history
Fix #4
  • Loading branch information
zhenyong97 authored Jan 18, 2024
2 parents da79222 + 53d0a08 commit 474a5db
Show file tree
Hide file tree
Showing 336 changed files with 58,693 additions and 13 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
[![ENV](https://img.shields.io/badge/release-v0.1-blue.svg)](https://github.com/pylixm/django-mdeditor)
[![ENV](https://img.shields.io/badge/pypi-v0.1-blue.svg)](https://pypi.org/project/Flask-MDEditor/)
[![ENV](https://img.shields.io/badge/中文-v0.1-blue.svg)](./README_CN.md)
[![ENV](https://img.shields.io/badge/python-3.7x-green.svg)]()
[![ENV](https://img.shields.io/badge/flask-1.0+-green.svg)]()
[![ENV](https://img.shields.io/badge/python-3.7+-green.svg)]()
[![ENV](https://img.shields.io/badge/flask-2.0+-green.svg)]()
[![LICENSE](https://img.shields.io/badge/license-MIT-green.svg)](./LICENSE)

![](./flask_and_mdeditor.png)
Expand Down Expand Up @@ -97,7 +97,7 @@ The more configuration options available are listed below:
|MDEDITOR_THEME|default|editor main theme|×|dark / default|
|MDEDITOR_PREVIEW_THEME|default|preview area theme|×| default / dark
|MDEDITOR_EDITOR_THEME|default|edit area theme|×| pastel-on-dark / default
|MDEDITOR_LANGUAGE|zh|editor language|×|zh / en
|MDEDITOR_LANGUAGE|en|editor language|×|zh / en

## TODO
* Unit Testing
Expand Down
3 changes: 2 additions & 1 deletion demo/flask_test/.flaskenv
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
FLASK_APP=app.py
FLASK_ENV=development
FLASK_ENV=development
FLASK_DEBUG=1
8 changes: 8 additions & 0 deletions demo/flask_test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Use Demo

```
pip install -r requirements.txt
flask run
```

8 changes: 4 additions & 4 deletions demo/flask_test/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class PostForm(FlaskForm):

@app.route('/')
def hello():
return render_template('index.html')
articles = Article.query.all()
return render_template('index.html', articles=articles)

@app.route('/post', methods=['GET', 'POST'])
def post():
Expand Down Expand Up @@ -59,14 +60,13 @@ def save():
@app.route('/get/<int:aritlce_id>')
def get_article(aritlce_id):
article = Article.query.get_or_404(aritlce_id)
mk = mistune.Markdown()
output = mk(article.content)
output = mistune.html(article.content)
return render_template('detail.html', article=article, content=output)


@app.cli.command()
def initdb():
"""创建数据库表"""
"""init testdb"""
import models
db.create_all()

Expand Down
15 changes: 15 additions & 0 deletions demo/flask_test/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
blinker==1.7.0
click==8.1.7
Flask==3.0.0
Flask-SQLAlchemy==3.1.1
Flask-WTF==1.2.1
greenlet==3.0.3
itsdangerous==2.1.2
Jinja2==3.1.3
MarkupSafe==2.1.3
mistune==3.0.2
python-dotenv==1.0.0
SQLAlchemy==2.0.25
typing_extensions==4.9.0
Werkzeug==3.0.1
WTForms==3.1.2
7 changes: 7 additions & 0 deletions demo/flask_test/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ <h1>Index Page</h1>
</ul>
{% endif %}
{% endwith %}
{% if articles %}
<ol>
{% for article in articles %}
<li><a href="{{ url_for('get_article', aritlce_id=article.id) }}">article.title - {{ article.id }}</a></li>
{% endfor %}
</ol>
{% endif %}

</body>
</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions flask_mdeditor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
:copyright: (c) 2020 by Zisc Li
:license: MIT, see LICENSE for more details.
"""
from flask import current_app, Markup, request, Blueprint, url_for, render_template_string, render_template, request
from flask import current_app, request, Blueprint, url_for, render_template_string, render_template
from flask import send_from_directory, jsonify
from markupsafe import Markup
import os
from flask_mdeditor.utils import random_filename

Expand Down Expand Up @@ -48,7 +49,7 @@ def config(self):
'task_list': False,
'flow_chart': True,
'sequence': True,
'language': current_app.config.get("MDEDITOR_LANGUAGE",'zh'), # zh / en
'language': current_app.config.get("MDEDITOR_LANGUAGE",'en'), # zh / en
'watch': True, # Live preview
'lineWrapping': current_app.config.get('MDEDITOR_WRAPPING','False'), # lineWrapping
'lineNumbers': False # lineNumbers
Expand Down
Loading

0 comments on commit 474a5db

Please sign in to comment.