diff --git a/wowfunding/orm/orm.py b/wowfunding/orm/orm.py index c99972e..174db54 100644 --- a/wowfunding/orm/orm.py +++ b/wowfunding/orm/orm.py @@ -122,13 +122,14 @@ class Proposal(base): 'date_posted_epoch': self.date_added.strftime('%s'), 'date_posted': self.date_added.strftime('%b %d %Y %H:%M:%S'), 'headline': self.headline, - 'content': self.content, + 'content_markdown': self.content, 'category': self.category, 'funds_target': self.funds_target, 'funded_pct': self.funds_progress, 'addr_donation': self.addr_donation, 'status': self.status, - 'user': self.user.username + 'user': self.user.username, + 'id': self.id } @classmethod diff --git a/wowfunding/routes.py b/wowfunding/routes.py index 6193046..1f90cee 100644 --- a/wowfunding/routes.py +++ b/wowfunding/routes.py @@ -18,6 +18,11 @@ def about(): return make_response(render_template('about.html')) +@app.route('/api') +def api(): + return make_response(render_template('api.html')) + + @app.route('/proposal/add/disclaimer') def proposal_add_disclaimer(): return make_response(render_template(('proposal/disclaimer.html'))) diff --git a/wowfunding/static/css/wow.css b/wowfunding/static/css/wow.css index 1b502e0..dfd8d5a 100644 --- a/wowfunding/static/css/wow.css +++ b/wowfunding/static/css/wow.css @@ -208,7 +208,9 @@ a { } .card-header { - padding: .75rem 1.25rem; + padding: 0.5rem; + padding-left: 1.0rem; + font-size: 16px; margin-bottom: 0; background-color: rgba(0,0,0,.03); background: linear-gradient(90deg, #d253c829, #ffa93e69); @@ -428,4 +430,40 @@ ul.b { .media-body #comment{ word-break: break-all; +} + +.api_documentation code{ + background-color: #f3f3f3; + padding: 4px; + padding-top:2px; + padding-bottom:2px; +} + +.api_documentation pre{ + margin-top:0; + background-color: #f3f3f3; + padding: 4px; + font-size: 12px; + padding-left:8px; + + white-space: pre-wrap; /* Since CSS 2.1 */ + white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + word-wrap: break-word; /* Internet Explorer 5.5+ */ +} + +.api_documentation .api_container hr{ + margin-bottom: 14px; + margin-top: 12px; +} + +.api_documentation .api_container{ + margin-bottom: 60px; +} + +.sidebar .card-body{ + padding: 1.0rem; + padding-left: 1.25rem; + padding-right: 1.25rem; } \ No newline at end of file diff --git a/wowfunding/templates/api.html b/wowfunding/templates/api.html new file mode 100644 index 0000000..a438241 --- /dev/null +++ b/wowfunding/templates/api.html @@ -0,0 +1,77 @@ +{% extends "base.html" %} +{% block content %} + +
+
+
+

API documentation

+

+ Requests are made using standard HTTP and responses are returned in JSON format. +

+

+

+

+
+ +
+
GET /api/1/convert/wow-usd
+
+

+ WOW to USD conversion. Data from TradeOgre and CoinMarketCap. +

+ + Example: +
curl -vvX GET 'https://funding.wownero.com/api/1/convert/wow-usd?wow=1000'
+ + Response: +
{"usd": 6.7}
+
+ +
+
GET /api/1/proposals
+
+

+ Proposal listing. +

+ + Parameters: +
    +
  • status: the proposal status, from 0 to 5. Default is 1.
  • +
  • limit: limit results. Default is 20.
  • +
  • offset: offset results. Default is 0.
  • +
+ + Example: +
curl -vvX GET 'https://funding.wownero.com/api/1/proposals?offset=1&limit=1&status=0'
+ + Response: +
{
+    "data": [
+        {
+            "id": 15,
+            "user": "dsc",
+            "headline": "[Bounty] Memes",
+            "content": "### markdown Content",
+            "category": "marketing",
+            "addr_donation": "WW3LcKRi3vJGSn11256Q819gExLtfsR3DZeGneu7K55QeeS4YcKMaDAHZ16hRM2gmJT7pVRiTGesjCsJUNAJPTn42rnh7wZEa",
+            "date_posted": "Jul 09 2018 21:59:26",
+            "date_posted_epoch": "1531173566",
+            "funded_pct": 33.3333333333333,
+            "funds_target": 15000.0,
+            "status": 2
+        }
+    ]
+}
+
+
+ + {% include 'sidebar.html' %} +
+ + +
+ +{% endblock %} diff --git a/wowfunding/templates/navbar.html b/wowfunding/templates/navbar.html index 2247d24..4aebba3 100644 --- a/wowfunding/templates/navbar.html +++ b/wowfunding/templates/navbar.html @@ -22,6 +22,9 @@ + {% if logged_in %}