diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index c9e6ae076..8e73980ea 100755 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -64,9 +64,26 @@ You must add the dependency and its licence in https://github.com/MAIF/daikoku/b if you add features to Daikoku, don't forget to modify the user documentation -* https://github.com/MAIF/daikoku/tree/master/docs/manual +* https://github.com/MAIF/daikoku/tree/master/docs -to build the documentation, run the following command at the root of the repository +To run the documentation locally + +Navigate to the `manual` folder and install the Docusaurus dependencies: +```sh +cd manual && npm install +``` + +Launch the documentation server, then edit the markdown files located in the manual folder: +```sh +npm run start +``` + +To test the search bar, build the project first: +```sh +npm run build +``` + +to build the documentation, run the following command at the root of the repository: ```sh sh ./scripts/build.sh manual diff --git a/cli/README.md b/cli/README.md index edaa9e5e9..44921afe7 100644 --- a/cli/README.md +++ b/cli/README.md @@ -131,7 +131,7 @@ The CMS projects adhere to the following strict file structure: - `styles`: Contains CSS files. - `documentations` : Contains files that can be used as documentation page of APIs -# Dynamic nested routing +# Dynamic routes The CLI uses file-system routing where folders are used to create nested routes. Each folder represents a route segment that maps to a URL segment. @@ -139,10 +139,12 @@ You can create separate UIs for each route using page.html files. `page.html` is To create a nested route, you can nest folders inside each other and add page.html files inside them. For example: -`src/pages/page.html`: can be reach on `/` path. -`src/pages/invoices/page.html`: can be reach on `/invoices` path. -`src/pages/offres.html`: can be reach on `/offres` path. -`src/pages/apis/api/[apiId]`: can be reach on `/apis/api/any-kind-of-api` and the apiId value can be use in the page as mustache variable using {{apiId}} +```sh +src/pages/page.html -> mysite.com/ +src/pages/invoices/page.html -> mysite.com/invoices +src/pages/offres.html -> mysite.com/offres +src/pages/apis/api/[apiId] -> mysite.com/apis/api/any-kind-of-api (the apiId value can be use in the page as mustache variable using {{apiId}}) +``` # Manage your assets @@ -369,14 +371,6 @@ When you have an user returned from directive, you can use the following fields {{translate 'Logout'}} ``` -## daikoku-path-param -`parameters`: -- the position of the path params - -```html -{{daikoku-path-param '0'}} -``` - ## daikoku-query-param `parameters`: - the name of the query param diff --git a/daikoku/app/domain/tenantEntities.scala b/daikoku/app/domain/tenantEntities.scala index dd2a5fd16..c56252358 100644 --- a/daikoku/app/domain/tenantEntities.scala +++ b/daikoku/app/domain/tenantEntities.scala @@ -1951,10 +1951,6 @@ case class CmsPage( "daikoku-generic-page-url", (id: String, _: Options) => s"/cms/pages/$id" ) - handlebars.registerHelper( - "daikoku-path-param", - (id: String, _: Options) => daikokuPathParam(ctx, id, req) - ) handlebars.registerHelper( "daikoku-query-param", (id: String, _: Options) => diff --git a/daikoku/javascript/src/components/adminbackoffice/cms/helpers.json b/daikoku/javascript/src/components/adminbackoffice/cms/helpers.json index cafb0dc3b..7da2dad4e 100644 --- a/daikoku/javascript/src/components/adminbackoffice/cms/helpers.json +++ b/daikoku/javascript/src/components/adminbackoffice/cms/helpers.json @@ -166,14 +166,6 @@ "example": "{{translate 'Logout'}}}", "category": "OPERATION" }, - { - "name": "daikoku-path-param", - "parameters": [ - "the position of the path params" - ], - "example": "{{daikoku-path-param '0'}}", - "category": "OPERATION" - }, { "name": "daikoku-query-param", "parameters": [ diff --git a/daikoku/javascript/src/locales/en/translation.json b/daikoku/javascript/src/locales/en/translation.json index 489045064..0edb999dc 100644 --- a/daikoku/javascript/src/locales/en/translation.json +++ b/daikoku/javascript/src/locales/en/translation.json @@ -1118,7 +1118,6 @@ "cms.content_side_view.ifnoteq": "Checks if the variable if not equals to the value", "cms.content_side_view.getOrElse": "Evaluates the value of the variable and return us the alternative value if the value is empty", "cms.content_side_view.translate": "Translates the variable using Daikoku translations", - "cms.content_side_view.daikoku-path-param": "Get the nth path params", "cms.content_side_view.daikoku-query-param": "Get the query param of name", "cms.content_side_view.daikoku-template-wrapper": "Display a wrapper block of the passed id", "cms.content_side_view.daikoku-apis": "Get all APIs", diff --git a/daikoku/javascript/src/locales/fr/translation.json b/daikoku/javascript/src/locales/fr/translation.json index e9f647f0b..720bae3fc 100644 --- a/daikoku/javascript/src/locales/fr/translation.json +++ b/daikoku/javascript/src/locales/fr/translation.json @@ -1118,7 +1118,6 @@ "cms.content_side_view.ifnoteq": "S'assure que la variable n'est pas égale à la valeur souhaitée", "cms.content_side_view.getOrElse": "Évalue la valeur de la variable et retourne l'alternative de la valeur si elle est non définie", "cms.content_side_view.translate": "Traduit une variable en utilisant les traduction de Daikoku", - "cms.content_side_view.daikoku-path-param": "Récupère le énième path param", "cms.content_side_view.daikoku-query-param": "Récupère le query param avec le nom passé en paramètre", "cms.content_side_view.daikoku-template-wrapper": "Affiche un bloc englobant un contenu enfant (avec ID)", "cms.content_side_view.daikoku-apis": "Récupère toutes les APIs", diff --git a/daikoku/test/daikoku/TenantControllerSpec.scala b/daikoku/test/daikoku/TenantControllerSpec.scala index aae4441b8..e56a82332 100644 --- a/daikoku/test/daikoku/TenantControllerSpec.scala +++ b/daikoku/test/daikoku/TenantControllerSpec.scala @@ -1246,30 +1246,6 @@ class TenantControllerSpec() //redirect to error page resp.status mustBe 303 } - "get a path param from cms page" in { - val page = defaultCmsPage.copy( - id = CmsPageId("foo-page"), - path = Some("/foo"), - body = "{{daikoku-path-param '0'}}" - ) - setupEnvBlocking( - tenants = Seq(tenant), - users = Seq(tenantAdmin), - teams = Seq(defaultAdminTeam), - cmsPages = Seq(page), - apis = Seq(adminApi) - ) - - val session = loginWithBlocking(tenantAdmin, tenant) - - val resp = httpJsonCallBlocking( - path = s"/_${page.path.get}/bar", - headers = Map("accept" -> "text/html") - )(tenant, session) - - resp.status mustBe 200 - resp.body mustBe "bar" - } "get the query params from cms page" in { val page = defaultCmsPage.copy( id = CmsPageId("query-params"), diff --git a/manual/docs/04-cli/index.mdx b/manual/docs/04-cli/index.mdx index de8ad575a..62156d409 100644 --- a/manual/docs/04-cli/index.mdx +++ b/manual/docs/04-cli/index.mdx @@ -154,333 +154,500 @@ daikokucli login # CMS Directives -## daikoku-user - -`parameters`: -- string user id -```html -{{#daikoku-user "{{userId}}"}} -
- {{user.name}} - -
-{{/daikoku-user}} -``` - -## daikoku-owned-apis - -`parameters` -- visibility: can be Private | Public | All -```html -{{#daikoku-owned-apis visibility="Private"}} - Mon api : {{api.name}} -{{/daikoku-owned-apis}} -``` - -## daikoku-owned-api -`parameters`: -- String API id -- The API version is optional, but it defaults to 1.0.0 when not specified. +
+ + daikoku-user + + Parameters + + + ```html + {{#daikoku-user "{{userId}}"}} +
+ {{user.name}} + +
+ {{/daikoku-user}} + ``` +
+ + +
+ + daikoku-owned-apis + + Parameters + + + ```html + {{#daikoku-owned-apis visibility="Private"}} + Mon api : {{api.name}} + {{/daikoku-owned-apis}} + ``` +
+ +
+ + daikoku-owned-api + + Parameters + -```html -{{#daikoku-owned-api "{{apiId}}" version="1.0.0"}} - Mon api : {{api.name}} -{{/daikoku-owned-api}} -``` - -## daikoku-json-owned-apis -`parameters`: -- Visibility : Private, Public or All -```html -{{#daikoku-json-owned-apis visibility="Private"}} - -{{/daikoku-json-owned-apis}} -``` + ```html + {{#daikoku-owned-api "{{apiId}}" version="1.0.0"}} + Mon api : {{api.name}} + {{/daikoku-owned-api}} + ``` +
+ +
+ + daikoku-json-owned-apis + + Parameters + + + ```html + {{#daikoku-json-owned-apis visibility="Private"}} + + {{/daikoku-json-owned-apis}} + ``` +
-## daikoku-json-owned-api -`parameters`: -- The API id, string value expected -- The API version is optional, but it defaults to 1.0.0 when not specified. - -```html -{{#daikoku-json-owned-api "{{apiId}}" version="1.0.0"}} -{{/daikoku-json-owned-api}} -``` - -## daikoku-owned-teams - -```html -{{#daikoku-owned-teams}} - Ma team : {{team.name}} -{{/daikoku-owned-teams}} -``` - -## daikoku-owned-team -`parameters`: -- The team ID, string value expected" -```html -{{#daikoku-owned-team "{{teamId}}"}} - Mon team : {{team.name}} -{{/daikoku-owned-team}} -``` - -## daikoku-json-owned-teams - -```html -{{daikoku-json-owned-teams}} -``` - -## daikoku-json-owned-team -`parameters`: -- The Team ID, String value expected - -```html -{{#daikoku-json-owned-team "{{teamId}}"}} - -{{/daikoku-json-owned-team}} -``` - -## tenant - -```html -{{tenant.name}} - {{tenant.style.description}} -``` - -## is_admin +
+ + daikoku-json-owned-api + + Parameters + + + ```html + {{#daikoku-json-owned-api "{{apiId}}" version="1.0.0"}} + {{/daikoku-json-owned-api}} + ``` +
+ +
+ + daikoku-owned-teams + + + ```html + {{#daikoku-owned-teams}} + Ma team : {{team.name}} + {{/daikoku-owned-teams}} + ``` +
+ +
+ + daikoku-owned-team + + Parameters + + + ```html + {{#daikoku-owned-team "{{teamId}}"}} + Mon team : {{team.name}} + {{/daikoku-owned-team}} + ``` +
+ + +
+ + daikoku-json-owned-teams + + + ```html + {{daikoku-json-owned-teams}} + ``` +
+ +
+ + daikoku-json-owned-team + + Parameters + + + ```html + {{#daikoku-json-owned-team "{{teamId}}"}} + + {{/daikoku-json-owned-team}} + ``` +
+ +
+ + tenant + + + ```html + {{tenant.name}}
  • {{tenant.style.description}} + ``` +
  • + +
    + + is_admin + -```html -{{is_admin}} -``` + ```html + {{is_admin}} + ``` +
    -## connected +
    + + connected + -```html -{{connected}} -``` + ```html + {{connected}} + ``` +
    -## user +
    + + user + -When you have an user returned from directive, you can use the following fields + When you have an user returned from directive, you can use the following fields - - `name` - - `email` - - `_id` - - `_humandReadableId` - - `picture` - - `isDaikokuAdmin` - - `starredApis` - -```html -
    - {{user.name}} - {{user.email}} -
    -``` - -## request -```html -
    - {{request.path}} - {{request.method}} - {{request.headers}} -
    -``` + - `name` + - `email` + - `_id` + - `_humandReadableId` + - `picture` + - `isDaikokuAdmin` + - `starredApis` + + ```html +
    + {{user.name}} - {{user.email}} +
    + ``` +
    -## daikoku-css -```html -
    - {{daikoku-css}} -
    -``` +
    + + request + + + ```html +
    + {{request.path}} - {{request.method}} - {{request.headers}} +
    + ``` +
    -## for -`parameters`: -- the fieldname used in the helper content +
    + + daikoku-css + + + ```html +
    + {{daikoku-css}} +
    + ``` +
    + +
    + + for + + Parameters + -``` -{{#for '{{team.users}}' field='myuser' }} - {{myuser.userId}} -{{/for}} -``` - -## size + ``` + {{#for '{{team.users}}' field='myuser' }} + {{myuser.userId}} + {{/for}} + ``` +
    + +
    + + size + -```html -{{size '{{team.users}}'}} -``` - -## ifeq - -```html -{{#ifeq "{{plan.type}}" "FreeWithoutQuotas"}} - You'll pay nothing and do whatever you want -{{/ifeq}} -``` - -## ifnoteq + ```html + {{size '{{team.users}}'}} + ``` +
    + +
    + + ifeq + + + ```html + {{#ifeq "{{plan.type}}" "FreeWithoutQuotas"}} + You'll pay nothing and do whatever you want + {{/ifeq}} + ``` +
    + +
    + + ifnoteq + -```html -{{#ifnoteq "{{plan.type}}" "FreeWithoutQuotas"}} - You'll pay nothing and do whatever you want -{{/ifnoteq}} -``` - -## getOrElse + ```html + {{#ifnoteq "{{plan.type}}" "FreeWithoutQuotas"}} + You'll pay nothing and do whatever you want + {{/ifnoteq}} + ``` +
    + +
    + + getOrElse + -```html -{{getOrElse "{{plan.customName}}" "Un plan"}} -``` - -## translate - -```html -{{translate 'Logout'}} -``` - -## daikoku-path-param -`parameters`: -- the position of the path params - -```html -{{daikoku-path-param '0'}} -``` - -## daikoku-query-param -`parameters`: -- the name of the query param - -```html -{{daikoku-query-param 'my-query-param'}} -``` - - -## daikoku-template-wrapper -`parameters`: -- Block path -- List of key=value usable in content - -```html -{{#daikoku-template-wrapper '' ="" }} - -{{/daikoku-template-wrapper}}" -``` - - -## daikoku-apis - -```html -{{#daikoku-apis}} - Api : {{api.name}} -{{/daikoku-apis}} -``` - -## daikoku-api - -`parameters`: -- API id, String value expected - -```html -{{#daikoku-api "{{apiId}}" version="1.0.0"}} - Mon api : {{api.name}} -{{/daikoku-api}}" -``` - -## daikoku-json-apis - -```html -{{daikoku-json-apis}} -``` - -## daikoku-json-api - -`parameters`: -- API Id, String value expected - -```html -{{#daikoku-json-api "{{apiId}}" version="1.0.0"}} - -{{/daikoku-json-api}} -``` - -## daikoku-teams - -```html -{{#daikoku-teams}} - Team : {{team.name}} -{{/daikoku-teams}} -``` - -## daikoku-team - -`parameters`: -- Team Id, String value expected - -```html -{{#daikoku-team "{{}}"}} - My team : {{team.name}} -{{/daikoku-team}} -``` - - -## daikoku-json-teams - -```html -{{daikoku-json-teams}} -``` - -## daikoku-json-team - -`parameters`: -- Team Id, String value expected - -```html -{{#daikoku-json-team "{{}}"}} - -{{/daikoku-json-team}} -``` - -## daikoku-documentations - -`parameters`: -- API id, String value expected + ```html + {{getOrElse "{{plan.customName}}" "Un plan"}} + ``` +
    + +
    + + translate + + + ```html + {{translate 'Logout'}} + ``` +
    + +
    + + daikoku-query-param + + Parameters + + + ```html + {{daikoku-query-param 'my-query-param'}} + ``` +
    + + +
    + + daikoku-template-wrapper + + Parameters + + + ```html + {{#daikoku-template-wrapper '' ="" }} + + {{/daikoku-template-wrapper}}" + ``` +
    + + +
    + + daikoku-apis + + + ```html + {{#daikoku-apis}} + Api : {{api.name}} + {{/daikoku-apis}} + ``` +
    + +
    + + daikoku-api + + Parameters + + + ```html + {{#daikoku-api "{{apiId}}" version="1.0.0"}} + Mon api : {{api.name}} + {{/daikoku-api}}" + ``` +
    + +
    + + daikoku-json-apis + + + ```html + {{daikoku-json-apis}} + ``` +
    + +
    + + daikoku-json-api + + Parameters + + + ```html + {{#daikoku-json-api "{{apiId}}" version="1.0.0"}} + + {{/daikoku-json-api}} + ``` +
    + +
    + + daikoku-teams + + + ```html + {{#daikoku-teams}} + Team : {{team.name}} + {{/daikoku-teams}} + ``` +
    + +
    + + daikoku-team + + Parameters + -```html -{{#daikoku-documentations "{{}}"}} - {{documentation.title}} -{{/daikoku-documentations}} -``` - -## daikoku-documentations-page + ```html + {{#daikoku-team "{{}}"}} + My team : {{team.name}} + {{/daikoku-team}} + ``` +
    + + +
    + + daikoku-json-teams + + + ```html + {{daikoku-json-teams}} + ``` +
    + +
    + + daikoku-json-team + + Parameters + -`parameters`: -- API ID, String value expected -- Page ID as String value + ```html + {{#daikoku-json-team "{{}}"}} + + {{/daikoku-json-team}} + ``` + +
    + +
    + + daikoku-documentations + + Parameters + -```html -{{#daikoku-documentations-page "" page=""}} - {{documentation.content}} -{{/daikoku-documentations-page}} -``` - -## daikoku-documentations-page-id - -`parameters`: -- Team ID, String value expected -- The named page parameter corresponding to the id of the expected page - -```html -{{#daikoku-documentations-page-id "" page=""}} - {{content}} -{{/daikoku-documentations-page-id}}" -``` - -## daikoku-plans + ```html + {{#daikoku-documentations "{{}}"}} + {{documentation.title}} + {{/daikoku-documentations}} + ``` +
    + +
    + + daikoku-documentations-page + + Parameters + -`parameters`: -- API ID - -```html -{{#daikoku-plans ""}} - {{plan.type}} -{{/daikoku-plans}} -``` + ```html + {{#daikoku-documentations-page "" page=""}} + {{documentation.content}} + {{/daikoku-documentations-page}} + ``` +
    + +
    + + daikoku-documentations-page-id + + Parameters + + + ```html + {{#daikoku-documentations-page-id "" page=""}} + {{content}} + {{/daikoku-documentations-page-id}}" + ``` +
    + +
    + + daikoku-plans + + Parameters + + + ```html + {{#daikoku-plans ""}} + {{plan.type}} + {{/daikoku-plans}} + ``` +
    # License diff --git a/manual/docs/04-cli/tutorials.md b/manual/docs/04-cli/tutorials.md new file mode 100644 index 000000000..ccdcf2fc0 --- /dev/null +++ b/manual/docs/04-cli/tutorials.md @@ -0,0 +1,3 @@ +# Tutorials + +Coming soon. \ No newline at end of file