diff --git a/docs/.api.md b/docs/.api.md new file mode 100644 index 00000000..ddc805aa --- /dev/null +++ b/docs/.api.md @@ -0,0 +1,57 @@ + +## Add a new event + +POST +{: .label .label-orange} + +**`/event`** + +> info "info" +> `Content-Type` has to be `multipart/form-data` 'cause support image upload + + +**Params** + +| title | `string` | event's title | +| description | `string` | event's description (html accepted and sanitized) | +| place_name | `string` | the name of the place | +| place_address | `string` | the address of the place | +| start_datetime | `integer` | start timestamp | +| multidate | `integer` | is a multidate event? | +| tags | `array` | List of tags | +| recurrent | `object` | Recurrent event details | +| recurrent.frequency | `string` | could be `1w` or `2w` | +| recurrent.type | `string` | not used | +| recurrent.days | `array` | array of days | +| image | `image` | Image | + + +--- + +## Get current authenticated user + +GET +{: .label .label-green} + +**`/api/user`** + + + + + +**Response** +```json +{ + "description" : null, + "recover_code" : "", + "id" : 1, + "createdAt" : "2020-01-29T18:10:16.630Z", + "updatedAt" : "2020-01-30T22:42:14.789Z", + "is_active" : true, + "settings" : "{}", + "email" : "eventi@cisti.org", + "is_admin" : true +} +``` +--- + diff --git a/docs/.api_header.md b/docs/.api_header.md index f9cc77d0..79b77df8 100644 --- a/docs/.api_header.md +++ b/docs/.api_header.md @@ -1,6 +1,14 @@ --- layout: default title: API -permalink: /api +permalink: /dev/api +parent: Hacking nav_order: 8 --- + + +1. TOC +{:toc} + + + diff --git a/docs/.api_helpers.js b/docs/.api_helpers.js new file mode 100644 index 00000000..ea955137 --- /dev/null +++ b/docs/.api_helpers.js @@ -0,0 +1,8 @@ +exports.if_eq = function(a, b, opts) { + if (a == b) { + return opts.fn(this); + } else { + return opts.inverse(this); + } +} + diff --git a/docs/.api_template.hbs b/docs/.api_template.hbs index c1c236b4..bbbd21e5 100644 --- a/docs/.api_template.hbs +++ b/docs/.api_template.hbs @@ -1,20 +1,34 @@ {{#orphans}} -### {{description}} +## {{description}} {{type.names}} +{{#if_eq type.names 'POST'}} +{: .label .label-orange} +{{else}} {: .label .label-green} +{{/if_eq}} -`{{name}}` - -{{#each params}} -| {{name}} | `{{type.names}}` | {{{description}}} | -{{/each}} +**`{{name}}`** {{#each customTags}} > {{tag}} "{{tag}}" > {{{value}}} {{/each}} + +{{#if params}} +**Params** + +{{#each params}} +| {{name}} | `{{type.names}}` | {{{description}}} | +{{/each}} +{{/if}} + + +{{#each examples}} +{{{this}}} +{{/each}} +--- {{/orphans}} diff --git a/docs/assets/css/style.css b/docs/assets/css/style.css index 313386b2..8e79cdc3 100644 --- a/docs/assets/css/style.css +++ b/docs/assets/css/style.css @@ -4,7 +4,7 @@ } .navigation-list-item a { - color: blue; + color: #7253ed; } .navigation-list-item a:hover { @@ -18,4 +18,4 @@ html, body { .page-content h1:first-of-type { font-weight: 500; -} \ No newline at end of file +} diff --git a/docs/dev/api.md b/docs/dev/api.md new file mode 100644 index 00000000..66c28914 --- /dev/null +++ b/docs/dev/api.md @@ -0,0 +1,71 @@ +--- +layout: default +title: API +permalink: /dev/api +parent: Hacking +nav_order: 8 +--- + + +1. TOC +{:toc} + + + + +## Add a new event + +POST +{: .label .label-orange} + +**`/event`** + +> info "info" +> `Content-Type` has to be `multipart/form-data` 'cause support image upload + + +**Params** + +| title | `string` | event's title | +| description | `string` | event's description (html accepted and sanitized) | +| place_name | `string` | the name of the place | +| place_address | `string` | the address of the place | +| start_datetime | `integer` | start timestamp | +| multidate | `integer` | is a multidate event? | +| tags | `array` | List of tags | +| recurrent | `object` | Recurrent event details | +| recurrent.frequency | `string` | could be `1w` or `2w` | +| recurrent.type | `string` | not used | +| recurrent.days | `array` | array of days | +| image | `image` | Image | + + +--- + +## Get current authenticated user + +GET +{: .label .label-green} + +**`/api/user`** + + + + + +**Response** +```json +{ + "description" : null, + "recover_code" : "", + "id" : 1, + "createdAt" : "2020-01-29T18:10:16.630Z", + "updatedAt" : "2020-01-30T22:42:14.789Z", + "is_active" : true, + "settings" : "{}", + "email" : "eventi@cisti.org", + "is_admin" : true +} +``` +--- + diff --git a/pages/event/_id.vue b/pages/event/_id.vue index 16047b39..df51ddad 100644 --- a/pages/event/_id.vue +++ b/pages/event/_id.vue @@ -326,6 +326,9 @@ export default { min-height: 300px; max-width: 600px; width: 100%; + .el-dialog__body { + word-break: normal; + } } } diff --git a/server/api/index.js b/server/api/index.js index a18ffc70..095a16c1 100644 --- a/server/api/index.js +++ b/server/api/index.js @@ -26,6 +26,20 @@ api.use(express.json()) * @category User * @name /api/user * @type GET + * @example **Response** + * ```json +{ + "description" : null, + "recover_code" : "", + "id" : 1, + "createdAt" : "2020-01-29T18:10:16.630Z", + "updatedAt" : "2020-01-30T22:42:14.789Z", + "is_active" : true, + "settings" : "{}", + "email" : "eventi@cisti.org", + "is_admin" : true +} +``` */ api.get('/user', isAuth, (req, res) => res.json(req.user)) diff --git a/server/api/models/user.js b/server/api/models/user.js index 687d53ba..3d2fc470 100644 --- a/server/api/models/user.js +++ b/server/api/models/user.js @@ -4,7 +4,7 @@ module.exports = (sequelize, DataTypes) => { const User = sequelize.define('user', { settings: { type: DataTypes.JSON, - defaultValue: '{}' + defaultValue: [] }, email: { type: DataTypes.STRING,