Node.js based forum software built for the modern web
chore: stub files for intents client-side logic
Julian Lam52c0a3600efb
diff --git a/public/src/modules/intents.js b/public/src/modules/intents.jsnew file mode 100644index 0000000000..19fae02283--- /dev/null+++ b/public/src/modules/intents.js@@ -0,0 +1,23 @@+'use strict';++import { dialog } from 'bootbox';++export function get() {+ // Checks localStorage for whether an existing handle has been saved, and what intents they support+ // Multiple handles can be saved, so it should return a Map+}++export function save(handle, intents) {+ // Called by refresh, saves a handle into localStorage. Multiple handles can be active at any one time,+ // so possibly call get() and append the handle (or replace as necessary)+}++export function refresh(handle) {+ // Fires off a network request to backend to check whether the handle passed-in supports Activity Intents+ // should return { intents: Array }, where the array contains something like ['object', 'create'].+}++export function register() {+ // Throws a modal asking user to enter their Open Social Web handle+ // Use dialog(), template is at src/view/modals/intents/register.tpl+}\ No newline at end of filediff --git a/src/controllers/write/intents.js b/src/controllers/write/intents.jsnew file mode 100644index 0000000000..9a1fdba038--- /dev/null+++ b/src/controllers/write/intents.js@@ -0,0 +1,10 @@+'use strict';++const Intents = module.exports;++const helpers = require('../helpers');++Intents.query = async (req, res) => {+ const intents = [];+ helpers.formatApiResponse(200, res, { intents });+};\ No newline at end of filediff --git a/src/routes/write/index.js b/src/routes/write/index.jsindex b17a2b9768..fedc9c8bde 100644--- a/src/routes/write/index.js+++ b/src/routes/write/index.js@@ -43,6 +43,7 @@ Write.reload = async (params) => {router.use('/api/v3/chats', require('./chats')());router.use('/api/v3/flags', require('./flags')());router.use('/api/v3/search', require('./search')());+ router.use('/api/v3/intents', require('./intents')());router.use('/api/v3/admin', require('./admin')());router.use('/api/v3/files', require('./files')());router.use('/api/v3/utilities', require('./utilities')());diff --git a/src/routes/write/intents.js b/src/routes/write/intents.jsnew file mode 100644index 0000000000..f833b27f09--- /dev/null+++ b/src/routes/write/intents.js@@ -0,0 +1,13 @@+'use strict';++const router = require('express').Router();+const controllers = require('../../controllers');+const routeHelpers = require('../helpers');++const { setupApiRoute } = routeHelpers;++module.exports = function () {+ setupApiRoute(router, 'get', '/query', [], controllers.write.intents.query);++ return router;+};diff --git a/src/views/modals/intents/register.tpl b/src/views/modals/intents/register.tplnew file mode 100644index 0000000000..00807ddd43--- /dev/null+++ b/src/views/modals/intents/register.tpl@@ -0,0 +1,7 @@+<!-- Bootstrap modal++ - Shows existing registered handles+ - Bootstrap form input to register a new handle+ - Add button to kickstart handle registration++-->\ No newline at end of file