-
Notifications
You must be signed in to change notification settings - Fork 16
Closed
Description
Description
- As a Developer I want to add a new page with functionality to the site so that I can continue development without needing to fork frontend => subapp
- As a Developer I want a new blog index page that shows most popular posts from a currently non-supported source so that clients can continue to use existing blog => theming + controller + new backend call from within route controller
- As a developer I want to add logging / analytics as middleware to process all requests so that I can integrate with existing systems => middleware
Acceptance Criteria
- frontend application loads custom middleware from plugin in plugins directory
- frontend application can load existing express middleware directly from npm
- frontend application can load custom route with custom controller from theme
- frontend application can load custom middleware with custom controller from theme
- app loads successfully without any configured plugins or extensions
Implementation
PSUEDOCODE
// Find in node env:
CKAN_FE_PLUGINS="@ckan/logly mapPage"
CKAN_PLUGIN_DIRECTORY="/plugins"
CKAN_THEME_ROUTES="montreal"
CKAN_THEME_MIDDLEWARE=""
// coordinate various extension types here
function enableExtensions {
// check ENV for configured plugins
// if custom plugins -> enableCustomPlugin()
// if npm // each -> enableNodePlugin()
// check ENV for enabled theme extensions
// if theme routes -> enableThemeRoutes
// if theme middleware -> enableThemeMiddleware
}
function enableCustomPlugin(pluginPath, pluginName):
console.log(pluginPath)
app.use('/static', express.static(`./${pluginPath}/public`))
require(`./${pluginPath}/${pluginName}/index.js`)(app)
}
// require from node_modules and instantiate
function enableNodePlugin {name}
// allows developer to create new routes that leverage theme resources
def enableThemeRoutes(themePath, theme) {
require('@ckan')(app)
}
// allows developer to enable theme-specific middleware
def enableThemeMiddleware(themePath, theme) {
require(`./${themePath}/${theme}/middleware.js`)
}@todo add validation and error handling to all extension loading (try /catch & warn)
Also see the closed pull request #12 for a working example that:
- dynamically loads routes from theme
- dynamically loads static resources
Tasks
- Implement support for required environment variables / config: [1hr]
CKAN_PLUGIN_DIRECTORY: Location of custom plugins, can be array (stretch), can default to/pluginsCKAN_FE_PLUGINS: space separated string of plugins to loadCKAN_THEME_ROUTES: space separated list of theme names withroutes.jsCKAN_THEME_MIDDLEWARE: space separated list of theme names withmiddleware.js- [OTHERS?]
- Implement plugin loading algorithms [above](Feature request: ability to add arbitrary route with template / controller / variables from path (and document) #11 implementation) [4hr]
- Test [3hr]
Metadata
Metadata
Assignees
Labels
No labels