Include contents page down side of wiki

This commit is contained in:
James Allen 2014-07-31 16:26:02 +01:00
parent be725c50ba
commit 55ad2ce78d
3 changed files with 38 additions and 18 deletions

View file

@ -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
}

View file

@ -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}
| !{page.content}

View file

@ -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;
}