From 55ad2ce78d5afcf9f487a0009a8b8c6149579432 Mon Sep 17 00:00:00 2001 From: James Allen Date: Thu, 31 Jul 2014 16:26:02 +0100 Subject: [PATCH] Include contents page down side of wiki --- .../Features/Wiki/WikiController.coffee | 26 ++++++++++++------- services/web/app/views/wiki/page.jade | 13 +++++----- services/web/public/stylesheets/app/wiki.less | 17 +++++++++++- 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/services/web/app/coffee/Features/Wiki/WikiController.coffee b/services/web/app/coffee/Features/Wiki/WikiController.coffee index 624e4e8917..8e743a634c 100644 --- a/services/web/app/coffee/Features/Wiki/WikiController.coffee +++ b/services/web/app/coffee/Features/Wiki/WikiController.coffee @@ -8,27 +8,33 @@ module.exports = WikiController = page = req.url.replace(/^\/learn/, "").replace(/^\//, "") if page == "" page = "Main_Page" - - wikiUrl = "#{settings.apis.wiki.url}/learn-scripts/api.php" - logger.log page: page, "proxying request to wiki" + logger.log page: page, "getting page from wiki" + WikiController._getPageContent "Contents", (error, contents) -> + return next(error) if error? + WikiController._getPageContent page, (error, page) -> + return next(error) if error? + res.render "wiki/page", { + page: page + contents: contents + } + + _getPageContent: (page, callback = (error, data = { content: "", title: "" }) ->) -> request { - url: wikiUrl + url: "#{settings.apis.wiki.url}/learn-scripts/api.php" qs: { page: decodeURI(page) action: "parse" format: "json" } }, (err, response, data)-> - if response?.statusCode == 404 - return ErrorController.notFound(req, res, next) + return callback(err) if err? try data = JSON.parse(data) catch err logger.err err:err, data:data, "error parsing data from wiki" - logger.log data: data, "got response from wiki" - res.render "wiki/page", { - content: data.parse.text['*'] - title: data.parse.title + callback null, { + content: data?.parse?.text?['*'] + title: data?.parse?.title } diff --git a/services/web/app/views/wiki/page.jade b/services/web/app/views/wiki/page.jade index 903d2a5097..d55ce41695 100644 --- a/services/web/app/views/wiki/page.jade +++ b/services/web/app/views/wiki/page.jade @@ -4,14 +4,13 @@ block content .content .container.wiki .row - .col-lg-8.col-lg-offset-2.col-md-10.col-md-offset-1 + .col-xs-3.contents + | !{contents.content} + .col-xs-8.page .page-header - - if (title == "Main Page") + - if (page.title == "Main Page") h1 ShareLaTeX Documentation - else - h1 #{title} - a(href="/learn") - i.fa.fa-long-arrow-left - |   Back to all articles + h1 #{page.title} - | !{content} \ No newline at end of file + | !{page.content} \ No newline at end of file diff --git a/services/web/public/stylesheets/app/wiki.less b/services/web/public/stylesheets/app/wiki.less index 4cbf995de8..cd4022dd89 100644 --- a/services/web/public/stylesheets/app/wiki.less +++ b/services/web/public/stylesheets/app/wiki.less @@ -1,4 +1,19 @@ .wiki { + .contents { + ul { + padding: 0; + li { + font-size: 14px; + list-style: none; + margin-bottom: 6px; + } + } + + h2 { + font-size: 18px; + } + } + .page-header { a { font-size: 0.8em; @@ -43,7 +58,7 @@ } } } - @media (min-width: 1190px) { + @media (min-width: 1360px) { .example { margin-right: -200px; }