This repository has been archived by the owner on Feb 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
feat(): Adds a way to display content from GitHub to the website #24
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const mdMirror = require('md-mirror') | ||
|
||
module.exports = (req, res) => { | ||
|
||
const mm = new mdMirror({ | ||
baseLocalUrl: '/md', | ||
baseRemoteUrl: 'https://raw.githubusercontent.com/openfab-lab', | ||
viewManager: (content) => { | ||
// While caching is not available set pages to be cached 24h | ||
res.setHeader('Cache-Control', 'public, max-age=' + (60*60*24)); | ||
res.render('../src/views/md.ejs', { | ||
content, | ||
user: req.user | ||
}) | ||
} | ||
}) | ||
|
||
return mm.render(req.url) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<%- include('./layout/top', {page: 'membre'}); %> | ||
<!-- IFRAME TRICK --> | ||
<!-- | ||
<div class="container-fluid"> | ||
<div class="row"> | ||
<div class="embed-responsive embed-responsive-16by9"> | ||
<iframe class="embed-responsive-item" srcdoc="<html> | ||
<head><%= '<link rel="stylesheet" href="https://unpkg.com/sakura.css/css/sakura.css" type="text/css">' %></head> | ||
<body><%= content %></body> | ||
</html>"></iframe> | ||
</div> | ||
</div> | ||
</div> | ||
--> | ||
|
||
<div class="container mdcontent mt-5"> | ||
<style>.mdcontent img { | ||
max-width: 100% | ||
}</style> | ||
<div class="row"> | ||
<div class="col-12"> | ||
<%- content %> | ||
</div> | ||
</div> | ||
</div> | ||
<%- include('./layout/bottom'); %> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
en fait, dût à autoroute (que j'ai opensourced ici btw: https://github.com/webinmove/barabara), tu dois pas déclarer ce qui est dans le dossier
controllers
:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
En fait pour avoir un module générique utilisable ailleurs, il est attendu que la fonction prenne en arguments
req, res
Il ne faut donc pas prendre la bretelle d'autoroute !
En revanche il faudrait peut-être le ranger ailleurs que dans le dossier scanné par 'autoroute'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
si tu peux injecter
req
etres
dans autoroute ;)tu dois faire ta méthode comme ceci :
module.exports.update = async (params, meta, req, res) => {
Les deux fonctionnent, mais si un jour tu veux tester correctement tes controllers, où (mais peut probable ici) si tu veux réutiliser la logique pour un worker ou autre, c'est plus simple ;)
Pour le fait qu'il soit dnas le même dossier pas de souci, autoroute ne fait que générer des un router express et tu overide cette route là par après avec
app.get('/md/*', mdDisplay);
donc pas de soucis, c'est prévu pour justement les edge case. Mais ici, c'en est pas un ;)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. Comment puis-je indiquer à autoroute que la route de ce controller sera
/md/*
et non pas/md
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ou je garde d'office l'override
app.get('/md/*', mdDisplay);
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oui, ok je vois, tu peux avoir des paths complets du style
md/mon/path/vers.md
?Soit tu overide, soit on rajoute une fonction
all
sur autouroute que tu peux du coup avoir dans ton controller et qui créera unmyRoute/*
, c'est pas une mauvise idée à ajouter à la lib tiens 🤔 Tu peux laisser l'override for now, je te pingerai quand la lib sera updatée ;)