mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Include contents page down side of wiki
This commit is contained in:
parent
be725c50ba
commit
55ad2ce78d
3 changed files with 38 additions and 18 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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}
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue