Browse Source

insertion works (not authenticated yet) and markdown parsing support

pull/1/head
wes 7 years ago
parent
commit
bb3ef2713e
  1. 2
      build/posts.py
  2. 18
      build/scripts/riotblog.min.js
  3. 11
      build/website.py
  4. 1
      package.json
  5. 2
      rollup.config.js
  6. 2
      src/posts.py
  7. 22
      src/scripts/editor.tag
  8. 6
      src/scripts/post.tag
  9. 1
      src/templates/write.html
  10. 11
      src/website.py
  11. 4
      yarn.lock

2
build/posts.py

@ -15,7 +15,7 @@ class Posts:
self.db = self.client["blog"]
def savepost(self, title, content, author):
def savepost(self, title="", content="", author=""):
doc = {
"title" : title,
"content" : content,

18
build/scripts/riotblog.min.js

File diff suppressed because one or more lines are too long

11
build/website.py

@ -50,11 +50,6 @@ def NeverWhere(configfile=None):
def stuff():
return render_template("projects.html")
@app.route("/blog/decision/", methods=("GET", "POST"))
def decision():
print("matched decision")
return render_template("decisions.html")
@app.route("/blog/", methods=("GET", "POST"))
def index():
print("matched index")
@ -73,9 +68,11 @@ def NeverWhere(configfile=None):
def send_style(filename):
return send_from_directory("/srv/http/riotblog/styles", filename)
@app.route("/blog/insert/")
@app.route("/blog/insert/", methods=("POST",))
def insert():
return posts.savepost(**request.args)
print("XXX")
print(request.form)
return posts.savepost(**request.form)
@app.route("/blog/switchpost/<pid>")
def getposts(pid):

1
package.json

@ -33,6 +33,7 @@
"axios": "^0.16.1",
"font-awesome": "^4.7.0",
"immutable": "^3.8.1",
"querystring": "^0.2.0",
"rollup-plugin-json": "^2.1.1",
"showdown": "^1.6.4",
"spectre.css": "^0.2.14",

2
rollup.config.js

@ -8,7 +8,7 @@ export default {
dest: 'build/bundle.js',
plugins: [
riot(),
nodeResolve({ jsnext: true }),
nodeResolve({ jsnext: true, preferBuiltins: false}),
commonjs(),
buble()
],

2
src/posts.py

@ -15,7 +15,7 @@ class Posts:
self.db = self.client["blog"]
def savepost(self, title, content, author):
def savepost(self, title="", content="", author=""):
doc = {
"title" : title,
"content" : content,

22
src/scripts/editor.tag

@ -30,7 +30,9 @@ import './raw.tag';
import 'whatwg-fetch';
import { default as showdown } from 'showdown';
import { default as R } from 'ramda';
import querystring from 'querystring';
this.R = R;
this.querystring = querystring;
this.converter = new showdown.Converter();
this.converted = "<h3>Nothing here yet</h3>";
@ -68,10 +70,26 @@ echo(ev) {
var self = this; /* Why do we need this??????????? */
submit() {
var post = {
var post = self.querystring.stringify({
"title" : "title",
"author" : "name",
"text" : this.refs.textarea.value
"content" : this.refs.textarea.value
});
var headers = {
"headers" : {
"Content-Type" : "application/x-www-form-urlencoded"
}
};
axios.post("/blog/insert/", post, headers)
.then(function(resp) {
console.log(resp);
})
.catch(function(err) {
console.log(err);
})
console.log("Submitting the post");
console.log(post);
}

6
src/scripts/post.tag

@ -9,7 +9,7 @@
<h4>{ this.title }</h4>
<h5>Posted by { this.author }</h5>
<p class="post-content centered text-break">
{ this.content }
<raw content="{ this.converter.makeHtml(this.content) }"></raw>
</p>
<div class="divider"></div>
</div>
@ -27,11 +27,15 @@
</div>
<script>
import './raw.tag';
import 'whatwg-fetch';
import { default as R } from 'ramda';
import { default as showdown } from 'showdown';
import './postcontrols.tag';
import route from 'riot-route';
this.converter = new showdown.Converter();
var self = this;
self.route = route;

1
src/templates/write.html

@ -28,6 +28,7 @@
{% block scripts %}
<script type="text/javascript" src="/blog/scripts/riotblog.min.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
{% endblock %}
</body>

11
src/website.py

@ -50,11 +50,6 @@ def NeverWhere(configfile=None):
def stuff():
return render_template("projects.html")
@app.route("/blog/decision/", methods=("GET", "POST"))
def decision():
print("matched decision")
return render_template("decisions.html")
@app.route("/blog/", methods=("GET", "POST"))
def index():
print("matched index")
@ -73,9 +68,11 @@ def NeverWhere(configfile=None):
def send_style(filename):
return send_from_directory("/srv/http/riotblog/styles", filename)
@app.route("/blog/insert/")
@app.route("/blog/insert/", methods=("POST",))
def insert():
return posts.savepost(**request.args)
print("XXX")
print(request.form)
return posts.savepost(**request.form)
@app.route("/blog/switchpost/<pid>")
def getposts(pid):

4
yarn.lock

@ -1026,6 +1026,10 @@ qs@~6.4.0:
version "6.4.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233"
querystring@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620"
ramda@^0.23.0:
version "0.23.0"
resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.23.0.tgz#ccd13fff73497a93974e3e86327bfd87bd6e8e2b"

Loading…
Cancel
Save