Commit d0ad4a8a authored by Matthieu Le Corre's avatar Matthieu Le Corre
Browse files

switch from showdown to markdown-it


Signed-off-by: Matthieu Le Corre's avatarMatthieu Le Corre <matthieu.lecorre@univ-nantes.fr>
parent f90ffd22
node_modules
......@@ -5,7 +5,6 @@ $eventDispatcher->addListener('OCA\Files::loadAdditionalScripts',
function() {
OCP\Util::addscript('files_readmemd', 'script');
OCP\Util::addscript('files_readmemd', 'vendor/showdown.min');
OCP\Util::addStyle('files_readmemd','style') ;
OCP\Util::addStyle('files_readmemd','content') ;
......
......@@ -7,7 +7,7 @@
With this app you can add a header and a footer to your nextcloud directories.
This can be use to explain the goal of a directory, describe the content of a folder ...
It show README.md in the way gitlab does.]]></description>
<version>1.0.2</version>
<version>1.0.3</version>
<licence>agpl</licence>
<author mail="matthieu.lecorre@univ-nantes.fr" homepage="http://www.univ-nantes.fr">Matthieu Le Corre</author>
<namespace>ReadMeMd</namespace>
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{
"name": "files_readmemd",
"version": "1.0.3",
"description": "show README.md github style",
"main": "./js/script.js",
"repository": "https://gitlab.univ-nantes.fr/uncloud/files_readmemd.git",
"author": "Matthieu Le Corre <matthieu.lecorre@univ-nantes.fr>",
"license": "AGPL-3.0",
"dependencies": {
"markdown-it": "^8.4.2"
},
"devDependencies": {
"webpack": "^4.29.6"
}
}
/**
* @namespace OCA.ReadmeMD
*/
OCA.ReadmeMD = {};
/**
* @namespace OCA.ReadmeMD.App
*/
OCA.ReadmeMD.App = {
/**
* Holds the MDs objects
*/
header: null,
readme: null,
/**
* Setup on page load
*/
initialize: function (header,readme) {
var self = this ;
// container creation
this.header = header;
this.readme = readme;
this.createContainer(this.header) ;
this.createContainer(this.readme) ;
// trigger on filetable to check if README/HEADER are present
$("#filestable").on('updated',function() { self.checkMD() ; })
//trigger on multiselect to handle the infamous fixed position toolsbar
$("#filestable").on('updated',function() {
$("#filestable input:checkbox").change(function() {
self.handleMultiselect() ;
});
});
},
/**
* check MD handler
*/
checkMD: function() {
//cleanup "old" MDs before checking for new ones
this.header.container.addClass("hidden") ;
this.header.container.children().remove() ;
this.header.content= null ;
this.readme.container.addClass("hidden") ;
this.readme.container.children().remove() ;
this.readme.content = null ;
//list file from current dir and check
for (var filenum in OCA.Files.App.fileList.files) {
if ( OCA.Files.App.fileList.files[filenum].name == this.header.filename ) {
this.header.container.removeClass("hidden") ;
this.fillContainer(OCA.ReadmeMD.header) ;
} ;
if ( OCA.Files.App.fileList.files[filenum].name == this.readme.filename ) {
this.readme.container.removeClass("hidden") ;
this.fillContainer(OCA.ReadmeMD.readme) ;
} ;
} ;
},
/**
* show contenair
*/
createContainer: function(zone) {
if (zone.position == "before")
{ $('#filestable').before(zone.container) ; }
if (zone.position == "after")
{ $('#filestable').after(zone.container) ; }
},
/**
* fill contant
*/
fillContainer: function(zone) {
var self=this ;
var dir=OCA.Files.App.fileList._currentDirectory ;
//load header file via remote call apps
$.get(OC.linkToRemoteBase('files'+ dir +"/" +zone.filename))
.done(function(data) {
//promise solved -> render MarkDown
zone.content=data ;
self.renderMD(zone) ;
}) ;
},
/**
* Render Markdown
**/
renderMD: function(zone) {
//render MD
var converter = require('markdown-it')() ;
zone.container.html(converter.render(zone.content)) ;
$("#filestable > tfoot > tr").height("auto") ;
},
/**
* Handle Multiselect
**/
handleMultiselect: function() {
// on checkbox change on filestable, check the multiselect class to hide header
// and move footer 70px down, see css
if ($("#filestable input:checked").size() > 0 ) {
this.header.container.addClass("hidden") ;
this.readme.container.addClass("down") ;
} else {
if (this.header.content != null) {
this.header.container.removeClass("hidden") ;
}
this.readme.container.removeClass("down") ;
}
}
};
OCA.ReadmeMD = OCA.ReadmeMD.App ;
$(document).ready(function () {
// Don't load if not in the files app
if (!$('#content.app-files').length) {
return;
} ;
var header = {
container: $('<div id="headerMD" class="hidden text-markdown headermd"></div>'),
position : "before",
filename : "HEADER.md",
content : null
} ;
var footer = {
container: $('<div id="readmeMD" class="hidden text-markdown readmemd"></div>'),
position : "after",
filename : "README.md",
content : null
} ;
OCA.ReadmeMD.initialize(header,footer);
});
const webpack = require("webpack");
const path = require("path");
let config = {
entry: "./src/script.js",
mode: 'none',
output: {
path: path.resolve(__dirname, "./js"),
filename: "script.js",
},
}
module.exports = config;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment