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

Add public shared rendering


Signed-off-by: Matthieu Le Corre's avatarMatthieu Le Corre <matthieu.lecorre@univ-nantes.fr>
parent c2dae427
## 1.0.2 08-04-2019
## 1.0.2 09-04-2019
### Added
- check for dot file, and prefer them ( .HEADER.md & .README.md)
[#4](https://gitlab.univ-nantes.fr/uncloud/files_readmemd/issues/4)
- Improve CSS default
[#7](https://gitlab.univ-nantes.fr/uncloud/files_readmemd/issues/7)
- Use of webpack to minimise the apps size, and handle dependancy
- Now render in public share
[#8](https://gitlab.univ-nantes.fr/uncloud/files_readmemd/issues/7)
### Removed
- remove all reference to markdown editor app
......
......@@ -3,9 +3,14 @@ $eventDispatcher = \OC::$server->getEventDispatcher();
$eventDispatcher->addListener('OCA\Files::loadAdditionalScripts',
function() {
OCP\Util::addscript('files_readmemd', 'script');
OCP\Util::addStyle('files_readmemd','style') ;
OCP\Util::addStyle('files_readmemd','content') ;
});
$eventDispatcher->addListener('OCA\Files_Sharing::loadAdditionalScripts',
function() {
OCP\Util::addscript('files_readmemd', 'script');
OCP\Util::addStyle('files_readmemd','style') ;
OCP\Util::addStyle('files_readmemd','content') ;
});
......@@ -3,6 +3,7 @@
border-top: 1px solid silver ;
margin-top: 1em ;
background-color: #c6d6390f ;
text-align: initial ;
}
.readmemd::before {
......@@ -13,6 +14,7 @@
.headermd {
padding: 1em ;
border-bottom: 1px solid silver ;
text-align: initial ;
}
.down {
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 70);
/******/ })
/************************************************************************/
/******/ ({
/***/ 70:
/***/ (function(module, exports) {
throw new Error("Module parse failed: Unexpected character '@' (1:0)\nYou may need an appropriate loader to handle this file type.\n> @font-face {\n| font-family: octicons-link;\n| src: url(data:font/woff;charset=utf-8;base64,d09GRgABAAAAAAZwABAAAAAACFQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEU0lHAAAGaAAAAAgAAAAIAAAAAUdTVUIAAAZcAAAACgAAAAoAAQAAT1MvMgAAAyQAAABJAAAAYFYEU3RjbWFwAAADcAAAAEUAAACAAJThvmN2dCAAAATkAAAABAAAAAQAAAAAZnBnbQAAA7gAAACyAAABCUM+8IhnYXNwAAAGTAAAABAAAAAQABoAI2dseWYAAAFsAAABPAAAAZwcEq9taGVhZAAAAsgAAAA0AAAANgh4a91oaGVhAAADCAAAABoAAAAkCA8DRGhtdHgAAAL8AAAADAAAAAwGAACfbG9jYQAAAsAAAAAIAAAACABiATBtYXhwAAACqAAAABgAAAAgAA8ASm5hbWUAAAToAAABQgAAAlXu73sOcG9zdAAABiwAAAAeAAAAME3QpOBwcmVwAAAEbAAAAHYAAAB/aFGpk3jaTY6xa8JAGMW/O62BDi0tJLYQincXEypYIiGJjSgHniQ6umTsUEyLm5BV6NDBP8Tpts6F0v+k/0an2i+itHDw3v2+9+DBKTzsJNnWJNTgHEy4BgG3EMI9DCEDOGEXzDADU5hBKMIgNPZqoD3SilVaXZCER3/I7AtxEJLtzzuZfI+VVkprxTlXShWKb3TBecG11rwoNlmmn1P2WYcJczl32etSpKnziC7lQyWe1smVPy/Lt7Kc+0vWY/gAgIIEqAN9we0pwKXreiMasxvabDQMM4riO+qxM2ogwDGOZTXxwxDiycQIcoYFBLj5K3EIaSctAq2kTYiw+ymhce7vwM9jSqO8JyVd5RH9gyTt2+J/yUmYlIR0s04n6+7Vm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zlSgUzzLBSikOPFTOXqly7rqx0Z1Q5BAIoZBSFihQYQOOBEdkCOgXTOHA07HAGjGWiIjaPZNW13/+lm6S9FT7rLHFJ6fQbkATOG1j2OFMucKJJsxIVfQORl+9Jyda6Sl1dUYhSCm1dyClfoeDve4qMYdLEbfqHf3O/AdDumsjAAB42mNgYoAAZQYjBmyAGYQZmdhL8zLdDEydARfoAqIAAAABAAMABwAKABMAB///AA8AAQAAAAAAAAAAAAAAAAABAAAAAA==) format('woff');");
/***/ })
/******/ });
/*# sourceMappingURL=styles.css.map*/
\ No newline at end of file
......@@ -17,10 +17,13 @@ OCA.ReadmeMD.App = {
/**
* Setup on page load
*/
initialize: function (header,readme) {
initialize: function (header,readme,mode) {
var self = this ;
//public share or private view
this.mode = mode ;
// container creation
this.header = header;
this.readme = readme;
......@@ -55,27 +58,33 @@ OCA.ReadmeMD.App = {
this.readme.container.children().remove() ;
this.readme.content = null ;
if (this.mode == "public") {
var FL = OCA.Sharing.PublicApp.fileList.files ;
}else {
var FL = OCA.Files.App.fileList.files ;
}
//list file from current dir and check
for (var filenum in OCA.Files.App.fileList.files) {
for (var filenum in FL ) {
if ( OCA.Files.App.fileList.files[filenum].name == this.header.filename ) {
if ( FL[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 ) {
if ( FL[filenum].name == this.readme.filename ) {
this.readme.container.removeClass("hidden") ;
this.fillContainer(OCA.ReadmeMD.readme) ;
} ;
//also check for dot files an prefer them.
if ( OCA.Files.App.fileList.files[filenum].name == "." + this.header.filename ) {
if ( FL[filenum].name == "." + this.header.filename ) {
this.header.filename = "." +this.header.filename ;
this.header.container.removeClass("hidden") ;
this.fillContainer(OCA.ReadmeMD.header) ;
} ;
if ( OCA.Files.App.fileList.files[filenum].name == "." + this.readme.filename ) {
if ( FL[filenum].name == "." + this.readme.filename ) {
this.readme.filename = "." +this.readme.filename ;
this.readme.container.removeClass("hidden") ;
this.fillContainer(OCA.ReadmeMD.readme) ;
......@@ -102,15 +111,22 @@ OCA.ReadmeMD.App = {
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) {
if (this.mode == 'public') {
var token = $('#sharingToken').val()
var dir = OCA.Sharing.PublicApp.fileList._currentDirectory ;
var URL = OC.generateUrl('/s/{token}/download?path={path}&files={file}', {token: token, path: dir, file: zone.filename});
}else{
var dir = OCA.Files.App.fileList._currentDirectory ;
var URL = OC.linkToRemoteBase('files'+ dir +"/" +zone.filename)
} ;
//load header file via remote call apps
$.get(URL)
.done(function(data) {
//promise solved -> render MarkDown
zone.content=data ;
self.renderMD(zone) ;
}) ;
}) ;
},
/**
......@@ -118,9 +134,9 @@ OCA.ReadmeMD.App = {
**/
renderMD: function(zone) {
//render MD
var converter = require('markdown-it')() ;
zone.container.html(converter.render(zone.content)) ;
$("#filestable > tfoot > tr").height("auto") ;
var converter = require('markdown-it')() ;
zone.container.html(converter.render(zone.content)) ;
$("#filestable > tfoot > tr").height("auto") ;
},
/**
......@@ -146,9 +162,15 @@ OCA.ReadmeMD = OCA.ReadmeMD.App ;
$(document).ready(function () {
// Don't load if not in the files app
if (!$('#content.app-files').length) {
return;
} ;
if ($('#content.app-files').length) {
var mode = 'private';
} else {
if ($('#content.app-files_sharing').length) {
var mode = 'public';
} else {
return ;
}
} ;
var header = {
container: $('<div id="headerMD" class="hidden markdown-body headermd"></div>'),
......@@ -164,7 +186,7 @@ $(document).ready(function () {
content : null
} ;
OCA.ReadmeMD.initialize(header,footer);
OCA.ReadmeMD.initialize(header,footer,mode);
});
......
......@@ -3,7 +3,7 @@ const path = require("path");
module.exports = {
devtool: 'source-map',
mode: 'none',
mode: 'production',
entry: {
'script.js': "./src/script.js"
......
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