diff --git a/config/dev.exs b/config/dev.exs index ae2ab7e5e..e3b746515 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -12,7 +12,7 @@ config :mobilizon, MobilizonWeb.Endpoint, ], url: [ host: System.get_env("MOBILIZON_INSTANCE_HOST") || "mobilizon.local", - port: 80, + port: System.get_env("MOBILIZON_INSTANCE_PORT") || 4000, scheme: "http" ], debug_errors: true, diff --git a/js/Makefile b/js/Makefile deleted file mode 100644 index c55170452..000000000 --- a/js/Makefile +++ /dev/null @@ -1,58 +0,0 @@ -# On OSX the PATH variable isn't exported unless "SHELL" is also set, see: http://stackoverflow.com/a/25506676 -SHELL = /bin/bash -NODE_BINDIR = ./node_modules/.bin -export PATH := $(NODE_BINDIR):$(PATH) - -# Where to find input files (it can be multiple paths). -INPUT_FILES = ./src - -# Where to write the files generated by this makefile. -OUTPUT_DIR = ./src/i18n - -# Available locales for the app. -LOCALES = en_US fr_FR - -# Name of the generated .po files for each available locale. -LOCALE_FILES ?= $(patsubst %,$(OUTPUT_DIR)/locale/%/LC_MESSAGES/app.po,$(LOCALES)) - -GETTEXT_HTML_SOURCES = $(shell find $(INPUT_FILES) -name '*.vue' -o -name '*.html' 2> /dev/null) -GETTEXT_JS_SOURCES = $(shell find $(INPUT_FILES) -name '*.vue' -o -name '*.js') - -# Makefile Targets -.PHONY: clean makemessages translations - -clean: - rm -f /tmp/template.pot $(OUTPUT_DIR)/translations.json - -makemessages: /tmp/template.pot - -translations: ./$(OUTPUT_DIR)/translations.json - -# Create a main .pot template, then generate .po files for each available language. -# Thanx to Systematic: https://github.com/Polyconseil/systematic/blob/866d5a/mk/main.mk#L167-L183 -/tmp/template.pot: $(GETTEXT_HTML_SOURCES) -# `dir` is a Makefile built-in expansion function which extracts the directory-part of `$@`. -# `$@` is a Makefile automatic variable: the file name of the target of the rule. -# => `mkdir -p /tmp/` - mkdir -p $(dir $@) - which gettext-extract -# Extract gettext strings from templates files and create a POT dictionary template. - gettext-extract --attribute v-translate --quiet --parseScript false --output $@ $(GETTEXT_HTML_SOURCES) -# Extract gettext strings from JavaScript files. - xgettext --language=JavaScript --keyword=npgettext:1c,2,3 \ - --from-code=utf-8 --join-existing --no-wrap \ - --package-name=$(shell node -e "console.log(require('./package.json').name);") \ - --package-version=$(shell node -e "console.log(require('./package.json').version);") \ - --output $@ $(GETTEXT_JS_SOURCES) -# Generate .po files for each available language. - @for lang in $(LOCALES); do \ - export PO_FILE=$(OUTPUT_DIR)/locale/$$lang/LC_MESSAGES/app.po; \ - echo "msgmerge --update $$PO_FILE $@"; \ - mkdir -p $$(dirname $$PO_FILE); \ - [ -f $$PO_FILE ] && msgmerge --lang=$$lang --update $$PO_FILE $@ || msginit --no-translator --locale=$$lang --input=$@ --output-file=$$PO_FILE; \ - msgattrib --no-wrap --no-obsolete -o $$PO_FILE $$PO_FILE; \ - done; - -$(OUTPUT_DIR)/translations.json: clean /tmp/template.pot - mkdir -p $(OUTPUT_DIR) - gettext-compile --output $@ $(LOCALE_FILES) diff --git a/js/package.json b/js/package.json index 4eb804f7f..26e3fdbcc 100644 --- a/js/package.json +++ b/js/package.json @@ -9,7 +9,7 @@ "dev": "vue-cli-service build --watch", "test:e2e": "vue-cli-service test:e2e", "test:unit": "vue-cli-service test:unit", - "prepare": "patch-package" + "vue-i18n-extract": "vue-i18n-extract" }, "dependencies": { "apollo-absinthe-upload-link": "^1.5.0", @@ -18,7 +18,6 @@ "apollo-link": "^1.2.11", "apollo-link-http": "^1.5.14", "buefy": "^0.8.2", - "easygettext": "^2.7.0", "graphql": "^14.2.1", "graphql-tag": "^2.10.1", "leaflet": "^1.4.0", @@ -33,7 +32,7 @@ "vue": "^2.6.10", "vue-apollo": "^3.0.0-rc.1", "vue-class-component": "^7.0.2", - "vue-gettext": "^2.1.3", + "vue-i18n": "^8.14.0", "vue-property-decorator": "^8.1.0", "vue-router": "^3.0.6", "vue2-leaflet": "^2.0.3", @@ -58,12 +57,12 @@ "eslint": "^6.0.1", "graphql-cli": "^3.0.12", "node-sass": "^4.11.0", - "patch-package": "^6.1.2", "sass-loader": "^8.0.0", "tslint": "^5.16.0", "tslint-config-airbnb": "^5.11.1", "typescript": "^3.4.3", "vue-cli-plugin-webpack-bundle-analyzer": "^1.3.0", + "vue-i18n-extract": "^1.0.2", "vue-svg-inline-loader": "^1.2.15", "vue-template-compiler": "^2.6.10", "webpack": "^4.30.0" diff --git a/js/patches/easygettext+2.7.0.patch b/js/patches/easygettext+2.7.0.patch deleted file mode 100644 index bdb2ce213..000000000 --- a/js/patches/easygettext+2.7.0.patch +++ /dev/null @@ -1,41 +0,0 @@ -patch-package ---- a/node_modules/easygettext/src/extract-cli.js -+++ b/node_modules/easygettext/src/extract-cli.js -@@ -22,9 +22,12 @@ const endDelimiter = argv.endDelimiter === undefined ? constants.DEFAULT_DELIMIT - const extraAttribute = argv.attribute || false; - const extraFilter = argv.filter || false; - const filterPrefix = argv.filterPrefix || constants.DEFAULT_FILTER_PREFIX; -+const parseScript = argv.parseScript === undefined ? true : argv.parseScript === 'true'; - - if (!quietMode && (!files || files.length === 0)) { -- console.log('Usage:\n\tgettext-extract [--attribute EXTRA-ATTRIBUTE] [--filterPrefix FILTER-PREFIX] [--output OUTFILE] '); -+ console.log( -+ 'Usage:\n\tgettext-extract [--attribute EXTRA-ATTRIBUTE] [--filterPrefix FILTER-PREFIX] [--parseScript BOOLEAN] [--output OUTFILE] ', -+ ); - process.exit(1); - } - -@@ -54,7 +57,7 @@ const extractor = new extract.Extractor({ - }); - - --files.forEach(function(filename) { -+files.forEach(function (filename) { - let file = filename; - const ext = file.split('.').pop(); - if (ALLOWED_EXTENSIONS.indexOf(ext) === -1) { -@@ -63,9 +66,13 @@ files.forEach(function(filename) { - } - console.log(`[${PROGRAM_NAME}] extracting: '${filename}`); - try { -- let data = fs.readFileSync(file, {encoding: 'utf-8'}).toString(); -+ let data = fs.readFileSync(file, { encoding: 'utf-8' }).toString(); - extractor.parse(file, extract.preprocessTemplate(data, ext)); - -+ if (!parseScript) { -+ return; -+ } -+ - if (ext !== 'js') { - data = extract.preprocessScriptTags(data, ext); - } diff --git a/js/src/App.vue b/js/src/App.vue index 73839d96e..c9fbf8be8 100644 --- a/js/src/App.vue +++ b/js/src/App.vue @@ -11,11 +11,20 @@ @@ -74,6 +98,8 @@ export default class App extends Vue { @import "~bulma/sass/components/navbar.sass"; @import "~bulma/sass/components/pagination.sass"; @import "~bulma/sass/components/dropdown.sass"; +@import "~bulma/sass/components/breadcrumb.sass"; +@import "~bulma/sass/components/list.sass"; @import "~bulma/sass/elements/box.sass"; @import "~bulma/sass/elements/button.sass"; @import "~bulma/sass/elements/container.sass"; @@ -84,6 +110,7 @@ export default class App extends Vue { @import "~bulma/sass/elements/tag.sass"; @import "~bulma/sass/elements/title.sass"; @import "~bulma/sass/elements/notification"; +@import "~bulma/sass/elements/table"; @import "~bulma/sass/grid/_all.sass"; @import "~bulma/sass/layout/_all.sass"; @@ -100,6 +127,7 @@ export default class App extends Vue { @import "~buefy/src/scss/components/upload"; @import "~buefy/src/scss/components/radio"; @import "~buefy/src/scss/components/switch"; +@import "~buefy/src/scss/components/table"; .router-enter-active, .router-leave-active { diff --git a/js/src/apollo/user.ts b/js/src/apollo/user.ts index f5920c6e0..be3273999 100644 --- a/js/src/apollo/user.ts +++ b/js/src/apollo/user.ts @@ -1,5 +1,6 @@ import { ApolloCache } from 'apollo-cache'; import { NormalizedCacheObject } from 'apollo-cache-inmemory'; +import { ICurrentUserRole } from '@/types/current-user.model'; export function buildCurrentUserResolver(cache: ApolloCache) { cache.writeData({ @@ -9,22 +10,44 @@ export function buildCurrentUserResolver(cache: ApolloCache { + updateCurrentUser: (_, { id, email, isLoggedIn, role }, { cache }) => { const data = { currentUser: { id, email, isLoggedIn, + role, __typename: 'CurrentUser', }, }; + cache.writeData({ data }); + }, + updateCurrentActor: (_, { id, preferredUsername, avatar, name }, { cache }) => { + const data = { + currentActor: { + id, + preferredUsername, + avatar, + name, + __typename: 'CurrentActor', + }, + }; + cache.writeData({ data }); }, }, diff --git a/js/src/components/Account/Identities.vue b/js/src/components/Account/Identities.vue index fb0870efa..c42c3f512 100644 --- a/js/src/components/Account/Identities.vue +++ b/js/src/components/Account/Identities.vue @@ -1,7 +1,7 @@ @@ -55,7 +55,7 @@ + \ No newline at end of file diff --git a/js/src/components/Event/TagInput.vue b/js/src/components/Event/TagInput.vue index 30c5326ef..6b357c94d 100644 --- a/js/src/components/Event/TagInput.vue +++ b/js/src/components/Event/TagInput.vue @@ -1,5 +1,5 @@