branch bow-v2-go updated (fff8634 -> ce51486)
This is an automated email from the git hooks/post-receive script. New change to branch bow-v2-go in repository bow. See https://gitlab.nuiton.org/chorem/bow.git from fff8634 on ne met plus d'en l'url les params qui ont la valeur par defaut new ce51486 stockage des images en base64 pas de creation de role s'il existe deja ajout de la visu de l'auth info The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit ce5148617e7258268e82bfe0936e791ef490353a Author: Benjamin <poussin@codelutin.com> Date: Mon May 25 17:01:24 2020 +0200 stockage des images en base64 pas de creation de role s'il existe deja ajout de la visu de l'auth info Summary of changes: migrate/001_init_schema.sql | 15 +++++++----- migrate/002_migration_data.sql | 6 ++--- migrate/003_migrate_image.sql | 24 +++++++++++++++++++ pkg/repository/bookmarkRepository.go | 25 +++++++++---------- web/package.json | 1 + web/src/components/Bookmark.vue | 6 +++-- web/src/components/bookmark/AuthenticationInfo.vue | 28 ++++++++++++++++++++++ web/src/main.js | 3 +++ web/yarn.lock | 12 ++++++++++ 9 files changed, 97 insertions(+), 23 deletions(-) create mode 100644 migrate/003_migrate_image.sql create mode 100644 web/src/components/bookmark/AuthenticationInfo.vue -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch bow-v2-go in repository bow. See https://gitlab.nuiton.org/chorem/bow.git commit ce5148617e7258268e82bfe0936e791ef490353a Author: Benjamin <poussin@codelutin.com> Date: Mon May 25 17:01:24 2020 +0200 stockage des images en base64 pas de creation de role s'il existe deja ajout de la visu de l'auth info --- migrate/001_init_schema.sql | 15 +++++++----- migrate/002_migration_data.sql | 6 ++--- migrate/003_migrate_image.sql | 24 +++++++++++++++++++ pkg/repository/bookmarkRepository.go | 25 +++++++++---------- web/package.json | 1 + web/src/components/Bookmark.vue | 6 +++-- web/src/components/bookmark/AuthenticationInfo.vue | 28 ++++++++++++++++++++++ web/src/main.js | 3 +++ web/yarn.lock | 12 ++++++++++ 9 files changed, 97 insertions(+), 23 deletions(-) diff --git a/migrate/001_init_schema.sql b/migrate/001_init_schema.sql index 81b09c7..b0d8b79 100644 --- a/migrate/001_init_schema.sql +++ b/migrate/001_init_schema.sql @@ -164,6 +164,7 @@ CREATE TRIGGER update_Bookmark_updateDate BEFORE INSERT OR UPDATE ON Bookmark FO -- nobody n'herite pas des droits des autres pour le force a faire un "set role" CREATE USER nobody WITH NOINHERIT CREATEROLE LOGIN PASSWORD '{{.nobody_password}}'; +DROP ROLE IF EXISTS person; CREATE ROLE person; -- l'utilisateur nobody a le droit d'inserer des users (creation de compte) et c'est lui qui visite les pages @@ -252,12 +253,14 @@ RETURNS TRIGGER AS $$ DECLARE id varchar := NEW."id"; BEGIN - -- creation du role pour l'utilisateur - execute 'CREATE ROLE "' || id || '"'; - -- nobody peut prendre ce role - execute 'GRANT "' || id || '" TO nobody'; - -- les users font parti du role person - execute 'GRANT person TO "' || id || '"'; + IF NOT EXISTS (SELECT * FROM pg_roles WHERE rolname = id) THEN + -- creation du role pour l'utilisateur + execute 'CREATE ROLE "' || id || '"'; + -- nobody peut prendre ce role + execute 'GRANT "' || id || '" TO nobody'; + -- les users font parti du role person + execute 'GRANT person TO "' || id || '"'; + END IF RETURN NEW; END; diff --git a/migrate/002_migration_data.sql b/migrate/002_migration_data.sql index dcf51ba..935e0b8 100644 --- a/migrate/002_migration_data.sql +++ b/migrate/002_migration_data.sql @@ -42,7 +42,7 @@ with 'form', __json->>'BowAuthentication.form', 'domain', __json->>'BowAuthentication.domain', 'domaincomponent', 3, - 'maxlength', __json->>'BowAuthentication.maxLength', + 'maxlength', (__json->>'BowAuthentication.maxLength')::smallint, 'allowedchar', __json->>'BowAuthentication.include', 'disallowedchar', __json->>'BowAuthentication.exclude', 'salt', __json->>'BowAuthentication.prefix', @@ -84,7 +84,7 @@ with 'form', __json->>'BowAuthentication.form', 'domain', __json->>'BowAuthentication.domain', 'domaincomponent', 3, - 'maxlength', __json->>'BowAuthentication.maxLength', + 'maxlength', (__json->>'BowAuthentication.maxLength')::smallint, 'allowedchar', __json->>'BowAuthentication.include', 'disallowedchar', __json->>'BowAuthentication.exclude', 'salt', __json->>'BowAuthentication.prefix', @@ -139,5 +139,5 @@ ALTER TABLE Bookmark ENABLE TRIGGER update_Bookmark_createDate; DELETE FROM actionHistory; DELETE FROM pageHistory; DELETE FROM bookmark; -DELETE FROM group; +DELETE FROM bowgroup; DELETE FROM bowUser; diff --git a/migrate/003_migrate_image.sql b/migrate/003_migrate_image.sql new file mode 100644 index 0000000..0a2ff44 --- /dev/null +++ b/migrate/003_migrate_image.sql @@ -0,0 +1,24 @@ +-- migration des images de bytea en text base64 + +ALTER TABLE bookmark ADD favicontext TEXT; +UPDATE bookmark SET favicontext=ENCODE(favicon, 'BASE64'); +ALTER TABLE bookmark DROP favicon; +ALTER TABLE bookmark RENAME favicontext TO favicon; + +ALTER TABLE bookmark ADD screenshottext TEXT; +UPDATE bookmark SET screenshottext=ENCODE(screenshot, 'BASE64'); +ALTER TABLE bookmark DROP screenshot; +ALTER TABLE bookmark RENAME screenshottext TO screenshot; + +---- create above / drop below ---- + +ALTER TABLE bookmark ADD faviconbytea bytea; +UPDATE bookmark SET faviconbytea=DECODE(favicon, 'BASE64'); +ALTER TABLE bookmark DROP favicon; +ALTER TABLE bookmark RENAME faviconbytea TO favicon; + +ALTER TABLE bookmark ADD screenshotbytea bytea; +UPDATE bookmark SET screenshotbytea=DECODE(screenshot, 'BASE64'); +ALTER TABLE bookmark DROP screenshot; +ALTER TABLE bookmark RENAME screenshotbytea TO screenshot; + diff --git a/pkg/repository/bookmarkRepository.go b/pkg/repository/bookmarkRepository.go index 5c16873..5cac40b 100644 --- a/pkg/repository/bookmarkRepository.go +++ b/pkg/repository/bookmarkRepository.go @@ -40,17 +40,19 @@ func BookmarkJSON(currentUser model.BowUser, id string, uri string, tags []strin } log.Printf("search bookmark id: %v, uri: %v, tags: '%v', fulltext: '%v', orderBy: %v, orderAsc: %v, first:%v", id, uri, tags, fulltext, orderBy, orderAsc, first) + var mainQuery string if id != "" { - q := &query{sql: `WITH __all AS (select * from bookmark where id=$1) SELECT json_agg(__all.*) as j FROM __all`} - result, err = q.QueryString(currentUser, id) + mainQuery = `select * from bookmark where id=$4` } else if uri != "" { - q := &query{sql: `WITH __all AS (select * from bookmark where uri=$1) SELECT json_agg(__all.*) as j FROM __all`} - result, err = q.QueryString(currentUser, uri) + mainQuery = `select * from bookmark where uri=$3` } else { - tagsJoined := strings.Join(tags, ",") - q := &query{sql: fmt.Sprintf(`WITH - __query AS (select * from bookmark where tags @> string_to_array($1, ',')), - __info AS (select %[3]d as first, %[4]d as limit, count(id) as total, '%[1]s' as orderby, to_json('%[2]s' = 'asc') as orderasc, string_to_array($1, ',') as tags, $2::TEXT as fulltext from __query), + mainQuery = `select * from bookmark where tags @> string_to_array($1, ',')` + } + + tagsJoined := strings.Join(tags, ",") + q := &query{sql: fmt.Sprintf(`WITH + __query AS (%[5]s), + __info AS (select %[3]d as first, %[4]d as limit, count(id) as total, '%[1]s' as orderby, to_json('%[2]s' = 'asc') as orderasc, string_to_array($1, ',') as tags, $2::TEXT as fulltext, $3::TEXT as uri, $4::TEXT as id from __query), __infoJson AS (select row_to_json(i.*) as info from __info i), __allTags AS (select unnest(tags) as tag from __query), __tags AS (select tag, count(tag) from __allTags group by tag order by 2 desc), @@ -58,10 +60,9 @@ func BookmarkJSON(currentUser model.BowUser, id string, uri string, tags []strin __result AS (select * from __query order by %[1]s %[2]s OFFSET %[3]d LIMIT %[4]d), __jsonResult AS (SELECT json_agg(r.*) as result FROM __result r) select row_to_json(v) from (select * from __infoJson, __jsonTags, __jsonResult) v; - `, orderBy, orderDirection, first, maxResult)} - result, err = q.QueryString(currentUser, tagsJoined, fulltext) - } - + `, orderBy, orderDirection, first, maxResult, mainQuery)} + result, err = q.QueryString(currentUser, tagsJoined, fulltext, uri, id) + if err != nil { return "", utils.NewHTTPError500(err, currentUser) } diff --git a/web/package.json b/web/package.json index ae2d420..2f1b7c5 100644 --- a/web/package.json +++ b/web/package.json @@ -11,6 +11,7 @@ "@johmun/vue-tags-input": "^2.1.0", "core-js": "^3.6.4", "vue": "^2.6.11", + "vue-dompurify-html": "^2.2.1", "vue-property-decorator": "^8.4.1", "vue-router": "^3.1.6", "vue-select": "^3.9.5", diff --git a/web/src/components/Bookmark.vue b/web/src/components/Bookmark.vue index 36cdcdb..cfc244f 100644 --- a/web/src/components/Bookmark.vue +++ b/web/src/components/Bookmark.vue @@ -19,6 +19,7 @@ </div> <!-- <span>{{ bookmark.authenticationinfo }}</span> faire afficher une popup de modification de l'objet auth--> <Description :description="bookmark.description"></Description> + <AuthenticationInfo v-if="bookmark.authenticationinfo" :authenticationinfo="bookmark.authenticationinfo"></AuthenticationInfo> <div class="info-footer"> <BookmarkDate :creationDate="date" :updateDate="bookmark.updatedate"></BookmarkDate> <Tags :tags="bookmark.tags"></Tags> @@ -47,6 +48,7 @@ import { Component, Prop, Vue } from 'vue-property-decorator' import Aliases from '@/components/bookmark/Alias' import BookmarkDate from '@/components/common/BookmarkDate' import Tags from '@/components/bookmark/Tags' +import AuthenticationInfo from '@/components/bookmark/AuthenticationInfo' import Description from '@/components/bookmark/Description' import LinkCount from '@/components/bookmark/LinkCount' import Visit from '@/components/bookmark/Visit' @@ -54,7 +56,7 @@ import Visit from '@/components/bookmark/Visit' @Component({ name: 'Bookmark', props: ['bookmark'], - components: { Aliases, BookmarkDate, Description, LinkCount, Tags, Visit } + components: { Aliases, AuthenticationInfo, BookmarkDate, Description, LinkCount, Tags, Visit } }) class Bookmark extends Vue { @Prop bookmark @@ -84,7 +86,7 @@ class Bookmark extends Vue { hexaToImg(hexa) { if (!hexa.startsWith('\\x')) { - return '' + return 'data:image/png;base64,' + hexa } let a = [] diff --git a/web/src/components/bookmark/AuthenticationInfo.vue b/web/src/components/bookmark/AuthenticationInfo.vue new file mode 100644 index 0000000..0e519d9 --- /dev/null +++ b/web/src/components/bookmark/AuthenticationInfo.vue @@ -0,0 +1,28 @@ +<template> + <div class="authenticationinfo"> + <div class="description" v-dompurify-html="authenticationinfo.description"></div> + <div class="form" v-dompurify-html="authenticationinfo.form"></div> + </div> +</template> + +<script> +import { Component, Prop, Vue } from 'vue-property-decorator' + +@Component({ + name: 'AuthenticationInfo', + props: ['authenticationinfo'], + components: {} +}) +class AuthenticationInfo extends Vue { + @Prop authenticationinfo +} + +export default AuthenticationInfo +</script> + +<style scoped lang="less"> +.authenticationinfo { + display: flex; + flex-direction: column; +} +</style> \ No newline at end of file diff --git a/web/src/main.js b/web/src/main.js index fed1c74..c23dab2 100644 --- a/web/src/main.js +++ b/web/src/main.js @@ -7,6 +7,7 @@ import router from './router' import store from './store' import FetchHelper from '@/utils/FetchHelper.js' import StoreHelper from './utils/Store' +import VueDOMPurifyHTML from 'vue-dompurify-html' window.BACKEND_URL = process.env.VUE_APP_BACKEND_URL window.FRONTEND_URL = process.env.BASE_URL @@ -17,6 +18,8 @@ if (typeof window !== 'undefined') { window.$storage = StoreHelper } +Vue.use(VueDOMPurifyHTML) + Vue.$fetch = FetchHelper Vue.$storage = StoreHelper diff --git a/web/yarn.lock b/web/yarn.lock index 06c9027..ee8d634 100644 --- a/web/yarn.lock +++ b/web/yarn.lock @@ -2913,6 +2913,11 @@ domhandler@^2.3.0: dependencies: domelementtype "1" +dompurify@^2.0.0: + version "2.0.11" + resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-2.0.11.tgz#cd47935774230c..." + integrity sha512-qVoGPjIW9IqxRij7klDQQ2j6nSe4UNWANBhZNLnsS7ScTtLb+3YdxkRY8brNTpkUiTtcXsCJO+jS0UCDfenLuA== + domutils@1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.5.1.tgz#dcd8488a26f563d61..." @@ -7958,6 +7963,13 @@ vue-class-component@^7.1.0: resolved "https://registry.yarnpkg.com/vue-class-component/-/vue-class-component-7.2.3..." integrity sha512-oEqYpXKaFN+TaXU+mRLEx8dX0ah85aAJEe61mpdoUrq0Bhe/6sWhyZX1JjMQLhVsHAkncyhedhmCdDVSasUtDw== +vue-dompurify-html@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/vue-dompurify-html/-/vue-dompurify-html-2.2.1.t..." + integrity sha512-ISInm/3VIeBmHy5yvmqjq6S0AVl1ozdK56d6iANd2h0jFF5W5MXBRGSnCYIb8aeJmsSqyFwnipvzfyReNmpwXA== + dependencies: + dompurify "^2.0.0" + vue-eslint-parser@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-7.0.0.tgz..." -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm