mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-14 23:35:31 +00:00
Proxy to wiki
This commit is contained in:
parent
87aa860c87
commit
49258fe3dd
6 changed files with 148 additions and 1 deletions
34
services/web/app/coffee/Features/Wiki/WikiController.coffee
Normal file
34
services/web/app/coffee/Features/Wiki/WikiController.coffee
Normal file
|
@ -0,0 +1,34 @@
|
|||
request = require("request")
|
||||
settings = require("settings-sharelatex")
|
||||
logger = require("logger-sharelatex")
|
||||
ErrorController = require "../Errors/ErrorController"
|
||||
|
||||
module.exports = WikiController =
|
||||
getPage: (req, res, next) ->
|
||||
page = req.url.replace(/^\/learn/, "").replace(/^\//, "")
|
||||
if page == ""
|
||||
page = "Main_Page"
|
||||
|
||||
wikiUrl = "#{settings.apis.wiki.url}/api.php"
|
||||
|
||||
logger.log page: page, "proxying request to wiki"
|
||||
|
||||
request {
|
||||
url: wikiUrl
|
||||
qs: {
|
||||
page: page
|
||||
action: "parse"
|
||||
format: "json"
|
||||
}
|
||||
}, (err, response, data)->
|
||||
if response?.statusCode == 404
|
||||
return ErrorController.notFound(req, res, next)
|
||||
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
|
||||
}
|
|
@ -37,6 +37,7 @@ PasswordResetRouter = require("./Features/PasswordReset/PasswordResetRouter")
|
|||
StaticPagesRouter = require("./Features/StaticPages/StaticPagesRouter")
|
||||
ChatController = require("./Features/Chat/ChatController")
|
||||
BlogController = require("./Features/Blog/BlogController")
|
||||
WikiController = require("./Features/Wiki/WikiController")
|
||||
ConnectedUsersController = require("./Features/ConnectedUsers/ConnectedUsersController")
|
||||
|
||||
logger = require("logger-sharelatex")
|
||||
|
@ -162,6 +163,8 @@ module.exports = class Router
|
|||
|
||||
app.get "/project/:Project_id/messages", SecurityManager.requestCanAccessProject, ChatController.getMessages
|
||||
app.post "/project/:Project_id/messages", SecurityManager.requestCanAccessProject, ChatController.sendMessage
|
||||
|
||||
app.get /learn(\/.*)?/, WikiController.getPage
|
||||
|
||||
#Admin Stuff
|
||||
app.get '/admin', SecurityManager.requestIsAdmin, AdminController.index
|
||||
|
|
17
services/web/app/views/wiki/page.jade
Normal file
17
services/web/app/views/wiki/page.jade
Normal file
|
@ -0,0 +1,17 @@
|
|||
extends ../layout
|
||||
|
||||
block content
|
||||
.content
|
||||
.container.wiki
|
||||
.row
|
||||
.col-lg-8.col-lg-offset-2.col-md-10.col-md-offset-1
|
||||
.page-header
|
||||
- if (title == "Main Page")
|
||||
h1 ShareLaTeX Documentation
|
||||
- else
|
||||
h1 #{title}
|
||||
a(href="/learn")
|
||||
i.fa.fa-long-arrow-left
|
||||
| Back to all articles
|
||||
|
||||
| !{content}
|
|
@ -65,7 +65,7 @@
|
|||
left: 50%;
|
||||
width: 400px;
|
||||
margin-left: -200px;
|
||||
margin-top: -140px;
|
||||
margin-top: -200px;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
92
services/web/public/stylesheets/app/wiki.less
Normal file
92
services/web/public/stylesheets/app/wiki.less
Normal file
|
@ -0,0 +1,92 @@
|
|||
.wiki {
|
||||
.page-header {
|
||||
a {
|
||||
font-size: 0.8em;
|
||||
line-height: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.editsection {
|
||||
display: none;
|
||||
}
|
||||
|
||||
table {
|
||||
th, td {
|
||||
padding: (@line-height-computed / 4) (@line-height-computed / 2);
|
||||
border-bottom: 1px solid @gray-lighter;
|
||||
}
|
||||
th {
|
||||
font-weight: 700;
|
||||
text-align: left;
|
||||
font-family: @font-family-serif;
|
||||
}
|
||||
margin-bottom: @line-height-computed / 2;
|
||||
}
|
||||
|
||||
.example {
|
||||
.code {
|
||||
pre {
|
||||
background-color: @gray-lightest;
|
||||
border-radius: 6px;
|
||||
padding: (@line-height-computed / 2);
|
||||
white-space: pre-wrap;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
.output {
|
||||
img {
|
||||
width: auto !important;
|
||||
height: auto !important;
|
||||
max-width: 100% !important;
|
||||
box-shadow: 0 1px 3px @gray-light;
|
||||
border-radius: 6px;
|
||||
}
|
||||
}
|
||||
}
|
||||
@media (min-width: 1190px) {
|
||||
.example {
|
||||
margin-right: -200px;
|
||||
}
|
||||
}
|
||||
|
||||
/*<![CDATA[*/
|
||||
.source-latex {line-height: normal;}
|
||||
.source-latex li, .source-latex pre {
|
||||
line-height: normal; border: 0px none white;
|
||||
}
|
||||
/**
|
||||
* GeSHi Dynamically Generated Stylesheet
|
||||
* --------------------------------------
|
||||
* Dynamically generated stylesheet for latex
|
||||
* CSS class: source-latex, CSS id:
|
||||
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
|
||||
* (http://qbnz.com/highlighter/ and http://geshi.org/)
|
||||
* --------------------------------------
|
||||
*/
|
||||
.latex.source-latex .imp {font-weight: bold; color: red;}
|
||||
.latex.source-latex li, .latex.source-latex .li1 {font-weight: normal; vertical-align:top;}
|
||||
.latex.source-latex .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
|
||||
.latex.source-latex .li2 {font-weight: bold; vertical-align:top;}
|
||||
.latex.source-latex .kw1 {color: #800000;}
|
||||
.latex.source-latex .co1 {color: #2C922C; font-style: italic;}
|
||||
.latex.source-latex .es0 {color: #000000; font-weight: bold;}
|
||||
.latex.source-latex .sy0 {color: #E02020; }
|
||||
.latex.source-latex .st0 {color: #000000;}
|
||||
.latex.source-latex .re1 {color: #8020E0; font-weight: normal;}
|
||||
.latex.source-latex .re2 {color: #C08020; font-weight: normal;}
|
||||
.latex.source-latex .re3 {color: #8020E0; font-weight: normal;}
|
||||
.latex.source-latex .re4 {color: #800000; font-weight: normal;}
|
||||
.latex.source-latex .re5 {color: #00008B; font-weight: bold;}
|
||||
.latex.source-latex .re6 {color: #800000; font-weight: normal;}
|
||||
.latex.source-latex .re7 {color: #0000D0; font-weight: normal;}
|
||||
.latex.source-latex .re8 {color: #C00000; font-weight: normal;}
|
||||
.latex.source-latex .re9 {color: #2020C0; font-weight: normal;}
|
||||
.latex.source-latex .re10 {color: #800000; font-weight: normal;}
|
||||
.latex.source-latex .re11 {color: #E00000; font-weight: normal;}
|
||||
.latex.source-latex .re12 {color: #800000; font-weight: normal;}
|
||||
.latex.source-latex .ln-xtra, .latex.source-latex li.ln-xtra, .latex.source-latex div.ln-xtra {background-color: #ffc;}
|
||||
.latex.source-latex span.xtra { display:block; }
|
||||
|
||||
/*]]>*/
|
||||
|
||||
}
|
|
@ -65,3 +65,4 @@
|
|||
@import "app/blog.less";
|
||||
@import "app/features.less";
|
||||
@import "app/templates.less";
|
||||
@import "app/wiki.less";
|
||||
|
|
Loading…
Add table
Reference in a new issue