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

Remove dependencies to File_editor & Markdown editor


Signed-off-by: Matthieu Le Corre's avatarMatthieu Le Corre <matthieu.lecorre@univ-nantes.fr>
parent e8bc3816
......@@ -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.1</version>
<version>1.0.2</version>
<licence>agpl</licence>
<author mail="matthieu.lecorre@univ-nantes.fr" homepage="http://www.univ-nantes.fr">Matthieu Le Corre</author>
<namespace>ReadMeMd</namespace>
......@@ -19,6 +19,6 @@ It show README.md in the way gitlab does.]]></description>
<bugs>https://gitlab.univ-nantes.fr/uncloud/files_readmemd/issues</bugs>
<screenshot>https://gitlab.univ-nantes.fr/uncloud/files_readmemd/raw/master/screenshot.png</screenshot>
<dependencies>
<nextcloud min-version="14" max-version="15"/>
<nextcloud min-version="14" max-version="16"/>
</dependencies>
</info>
......@@ -17,7 +17,7 @@ OCA.ReadmeMD.App = {
/**
* Setup on page load
*/
initialize: function (header,readme,editorType) {
initialize: function (header,readme) {
var self = this ;
......@@ -25,13 +25,11 @@ OCA.ReadmeMD.App = {
this.header = header;
this.readme = readme;
this.editorType = editorType ;
this.createContainer(this.header) ;
this.createContainer(this.readme) ;
// then trigger on filetable to check if README/HEADER are present
$("#filestable").on('updated',function() { self.checkMD() ; })
$("#filestable").on('updated',function() { self.checkMD() ; })
//trigger on multiselect to handle the infamous fixed position toolsbar
$("#filestable").on('updated',function() {
......@@ -49,29 +47,29 @@ OCA.ReadmeMD.App = {
*/
checkMD: function() {
//cleanup "old" MDs before checking for new ones
this.header.container.addClass("hidden") ;
this.header.container.children().remove() ;
this.header.content= null ;
//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) ;
} ;
} ;
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) ;
} ;
} ;
},
......@@ -96,16 +94,11 @@ OCA.ReadmeMD.App = {
var self=this ;
dir=OCA.Files.App.fileList._currentDirectory ;
//load header file via texteditor apps
$.get(
OC.generateUrl('/apps/files_texteditor/ajax/loadfile'),
{
filename: zone.filename,
dir: dir
}
).done(function(data) {
//load header file via remote call apps
$.get(OC.linkToRemoteBase('files'+ dir +"/" +zone.filename))
.done(function(data) {
//promise solved -> render MarkDown
zone.content=data.filecontents ;
zone.content=data ;
self.renderMD(zone) ;
}) ;
},
......@@ -115,19 +108,9 @@ OCA.ReadmeMD.App = {
**/
renderMD: function(zone) {
//render MD
if (this.editorType == "app" ) {
OCA.Files_Texteditor.previewPlugins["text/markdown"].renderer.renderText(
zone.content,
zone.container
).done(function(data) {
$("#filestable > tfoot > tr").height("auto") ;
});
} else {
var converter = new showdown.Converter();
zone.container.html(converter.makeHtml(zone.content)) ;
$("#filestable > tfoot > tr").height("auto") ;
} ;
},
/**
......@@ -149,7 +132,6 @@ OCA.ReadmeMD.App = {
};
OCA.ReadmeMD = OCA.ReadmeMD.App ;
$(document).ready(function () {
......@@ -172,21 +154,7 @@ $(document).ready(function () {
content : null
} ;
//Switch to alternate renderer if markdown app is not present
if (!OCA.Files_Texteditor.previewPlugins["text/markdown"] ){
console.warn('MarkDown Apps not available !') ;
console.warn('Switching to alternate markdown renderer') ;
OCA.ReadmeMD.initialize(header,footer,"vendor");
} else {
// wait for plugin init to load app
// initialise MD renderer
OCA.Files_Texteditor.loadPreviewPlugin("text/markdown").then(function() {
OCA.ReadmeMD.initialize(header,footer,"app");
}) ;
} ;
OCA.ReadmeMD.initialize(header,footer);
});
......
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