Yuki Takei 9 лет назад
Родитель
Сommit
95c85e807f

+ 11 - 0
packages/growi-plugin-lsx/src/lib/routes/index.js

@@ -0,0 +1,11 @@
+module.exports = function(crowi, app) {
+  var debug = require('debug')('crowi-plugin:lsx:routes')
+    , middleware = crowi.require('../util/middlewares')
+    , lsx = require('./lsx')(crowi, app)
+    , loginRequired = middleware.loginRequired
+    , accessTokenParser = middleware.accessTokenParser(crowi, app)
+    , csrf      = middleware.csrfVerify(crowi, app)
+    ;
+
+  app.get('/_api/plugins/lsx', accessTokenParser , loginRequired(crowi, app) , lsx.renderHtml);
+}

+ 29 - 0
packages/growi-plugin-lsx/src/lib/routes/lsx.js

@@ -0,0 +1,29 @@
+module.exports = function(crowi, app) {
+  var debug = require('debug')('crowi-plugin:lsx:routes:lsx')
+    , Page = crowi.model('Page')
+    , actions = {};
+
+  actions.renderHtml = function(req, res) {
+    debug(`rendering html for '${path}'`);
+
+    var path = '/Level2/';
+    var queryOptions = {};
+
+    // find pages
+    Page.findListByStartWith(path, req.user, queryOptions)
+      .then(function(pages) {
+        var renderVars = {};
+        renderVars.pages = pages;
+        renderVars.pager = false
+        renderVars.viewConfig = {};
+
+        // render widget
+        res.render('widget/page_list', renderVars);
+      })
+      .catch(function(err) {
+        debug('Error on rendering lsx.renderHtml', err);
+      });
+  }
+
+  return actions;
+};

+ 3 - 1
packages/growi-plugin-lsx/src/meta.js

@@ -1,6 +1,8 @@
 export default {
   pluginSchemaVersion: 2,
-  serverEntries: [],
+  serverEntries: [
+    './server-entry.js'
+  ],
   clientEntries: [
     './client-entry.js'
   ]

+ 3 - 0
packages/growi-plugin-lsx/src/server-entry.js

@@ -0,0 +1,3 @@
+export default (crowi, app) => {
+  require('./lib/routes')(crowi, app);
+}