Browse Source

增加markdown支持

master
wengsy 4 years ago
parent
commit
e8159b0491
4 changed files with 40 additions and 34 deletions
  1. +1
    -6
      .idea/workspace.xml
  2. +0
    -2
      APP/server.py
  3. +27
    -12
      APP/static/js/wsy.js
  4. +12
    -14
      APP/templates/add.html

+ 1
- 6
.idea/workspace.xml View File

@ -2,14 +2,9 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="ccd18ece-a4ed-4116-ada0-c6de56a9afb1" name="默认的" comment="">
<change beforePath="$PROJECT_DIR$/.idea/.gitignore" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/encodings.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/APP/static/js/wsy.js" beforeDir="false" afterPath="$PROJECT_DIR$/APP/static/js/wsy.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/APP/templates/personal.html" beforeDir="false" afterPath="$PROJECT_DIR$/APP/templates/personal.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/APP/templates/square.html" beforeDir="false" afterPath="$PROJECT_DIR$/APP/templates/square.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/APP/view/block.py" beforeDir="false" afterPath="$PROJECT_DIR$/APP/view/block.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/APP/view/database.py" beforeDir="false" afterPath="$PROJECT_DIR$/APP/view/database.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/APP/templates/add.html" beforeDir="false" afterPath="$PROJECT_DIR$/APP/templates/add.html" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />

+ 0
- 2
APP/server.py View File

@ -4,7 +4,6 @@ from APP.view.block import bp_block
from APP.view.start import bp_start
from APP.view.collection import bp_collection
from APP.view.database import init_db
from flask_cors import *
class CustomFlask(Flask):
@ -15,7 +14,6 @@ class CustomFlask(Flask):
variable_end_string='%%',
))
app = CustomFlask(__name__)
CORS(app, supports_credentials=True)
app.register_blueprint(bp_auth)
app.register_blueprint(bp_start)
app.register_blueprint(bp_block)

+ 27
- 12
APP/static/js/wsy.js View File

@ -132,15 +132,8 @@ function getContent(type) {
}
for (i in page.textList) {
page.textList[i]['order'] = i;
if (type == 'block' && page.textList[i]['type'] == 'picture') {
console.log(page.textList[i]);
// page.textList[i]['content'] = get_url(i);
}
}
compile();
});
}
@ -256,7 +249,7 @@ var page = new Vue({
edit: function (order, type) {
var obj = this.textList[order]
var pos = obj['order'];
var url = type + '/update';
var url = type + '/edit';
var data = new FormData();
if (type == 'collection') {
data.append('collection_id', obj['id']);
@ -273,9 +266,12 @@ var page = new Vue({
else {
data.append('collection_id', this.id);
data.append('block_id', obj['id']);
if (this.content != null) {
obj['content'] = this.content;
data.append('content', this.content);
if (obj['content'] != null) {
data.append('content', obj['content']);
}
if(obj['type'] == 'text'){
var converter = new showdown.Converter();
obj['html'] = converter.makeHtml(obj['content']);
}
}
@ -390,4 +386,23 @@ function CHECK_URL(url) {
} else {
return (false);
}
}
function compile(){
var list = document.getElementsByClassName("standard-input");
console.log(list,list.length);
for(i in page.textList){
if(page.textList[i]['type']!='text'){
page.textList[i]['html'] = null;
continue;
}
var text = page.textList[i]['content'];
console.log(i);
var converter = new showdown.Converter();
var html = converter.makeHtml(text);
page.textList[i]['html'] = html;
}
}

+ 12
- 14
APP/templates/add.html View File

@ -16,6 +16,7 @@
<link href="../static/css/charts.css" rel="stylesheet">
<link href="../static/css/main.css" rel="stylesheet">
<script src="../static/js/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="../static/js/showdown-master/dist/showdown.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
getContent('block');
@ -26,10 +27,6 @@
<!-- wsy:临时用样式 -->
<style>
.standard-input {
height: 100px;
width: 500px;
background-color: aliceblue;
margin-top: 1em;
}
</style>
</head>
@ -463,11 +460,11 @@
<div class="row" id="textList">
<!-- 集锦块样例 -->
<div class="col-md-4" v-for="item in textList" :key="item.id" v-bind:item='item'>
<div class="card mb-3 bg-mixed-hopes widget-chart text-white card-border">
<div class="main-card mb-3 card">
<div class="widget-chart-actions">
<div class="btn-group dropdown">
<button type="button" aria-haspopup="true" data-toggle="dropdown"
aria-expanded="false" class="text-white btn btn-link" v-if="id!='null'">
aria-expanded="false" class="btn btn-link" v-if="id!='null'">
<i class="fa fa-ellipsis-h"></i>
</button>
<div v-if="id!=null"tabindex="-1" role="menu" aria-hidden="true"
@ -486,9 +483,9 @@
<li class="nav-item-header nav-item" v-if="item.type!='picture' ">修改名称
</li>
<li class="nav-item" v-if="item.type!='picture' ">
<input type="text" autocomplete="off" v-model="content"
v-bind:placeholder="item.content"
class="form-control input-mask-trigger">
<textarea autocomplete="off" v-model="item.content"
class="form-control input-mask-trigger" ></textarea>
</li>
<li class="nav-item-btn nav-item" v-if="item.type!='picture' ">
<button class="btn-wide btn-shadow btn btn-danger btn-sm"
@ -498,19 +495,20 @@
</div>
</div>
</div>
<div class="widget-numbers">
<span v-if="item.type=='text'">{{item.content}}</span>
<img v-if="item.type=='picture'" v-bind:src="item.content" alt="" >
<div class="card-body">
<div v-if="item.type=='text'"><div v-html="item.html"></div></div>
<div class="standard-output"></div>
<img v-if="item.type=='picture'" v-bind:src="item.content" alt="" style="max-width:300px;">
<a v-if="item.type=='url'" v-bind:href="item.content">{{item.title}}</a>
</div>
</div>
</div>
<div class="col-md-4" v-show="id!='null'">
<div class="card mb-3 bg-mixed-hopes widget-chart text-white card-border">
<div class="main-card mb-3 widget-chart card card-border">
<div class="widget-chart-actions">
<div class="btn-group dropdown">
<button type="button" aria-haspopup="true" data-toggle="dropdown"
aria-expanded="false" class="text-white btn btn-link">
aria-expanded="false" class="btn btn-link">
<i class="pe-7s-plus"></i>
</button>
<div tabindex="-1" role="menu" aria-hidden="true"

Loading…
Cancel
Save