Skip to content

Commit

Permalink
Fixed merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoJokhan committed Jul 25, 2023
2 parents a295d14 + e370118 commit a5d38ed
Show file tree
Hide file tree
Showing 21 changed files with 288 additions and 19 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/gitops-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: GitopsDev

# Run this workflow every time a new commit pushed to your repository
on:
push:
branches:
- master
- development
- feature/*
- release/*
- release

jobs:
gitops:
environment: gitops_dev
env:
HELM_REPO_NAME: openstad-kubernetes
HELM_CHART_FOLDER: k8s/openstad
GIT_USER_EMAIL: github@ci.push
GIT_USER_NAME: GitHub
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
HELM_REPO: ${{ secrets.HELM_REPO }}
HELM_REPO_WITH_TOKEN: ${{ secrets.HELM_REPO_WITH_TOKEN }}
GITOPS_RELEASE_BRANCH: ${{ secrets.GITOPS_RELEASE_BRANCH }}
FRONTED_PORT: 4444
FRONTEND_MONGO_SCHEME: mongodb://mongo
FRONTEND_MONGO_DB_HOST: mongo
FRONTEND_MONGO_PORT: 27017
FRONTEND_MINIFY_JS: ON
COOKIE_SECURE_OFF: yes
API: http://localhost:8111
IMAGE_API_URL: http://localhost:3333
IMAGE_API_ACCESS_TOKEN: xxxx
SITE_API_KEY: xxxx
DEFAULT_DB: localhost2
DEFAULT_HOST: localhost:4444
APP_URL: http://localhost:4444
APOS_BUNDLE: assets
APOS_MINIFY: 1
NODE_ENV: production
BRANCH_REF: ${{ github.ref }}
GITOPS_VALUES_FILE: k8s/openstad/environments/dev.values.yaml

name: gitops commit
runs-on: ubuntu-latest

services:
docker:
image: docker
mongodb:
image: mongo:3.4.23
ports:
- 27017:27017

steps:
- name: Checkout code
uses: actions/checkout@v2


- name: Set environment to acc
id: acc_values_file
shell: bash
if: contains(github.ref, 'release')
run: echo "GITOPS_VALUES_FILE=k8s/openstad/environments/acc.values.yaml" >> $GITHUB_ENV

- name: Set environment to production
id: prod_values_file
shell: bash
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master'
run: echo "GITOPS_VALUES_FILE=k8s/openstad/environments/prod.values.yaml" >> $GITHUB_ENV

- name: Set commit SHA & current branch
id: vars
shell: bash
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
echo "::set-output name=current_branch::$(git branch --show-current | sed "s/\//-/g")"
- name: Install yq
run: sudo snap install yq --channel=v3/stable


- name: Run build script
run: |
sudo chmod a+x ./build.sh
./build.sh
shell: bash
env:
IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ steps.vars.outputs.current_branch }}-${{ steps.vars.outputs.sha_short }}-${{ github.run_id}}

- name: Run docker push script
run: |
sudo chmod a+x ./gitops_push
./gitops_push
shell: bash
env:
IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ steps.vars.outputs.current_branch }}-${{ steps.vars.outputs.sha_short }}-${{ github.run_id}}
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ env:
- GITOPS_ACC_VALUES_FILE=${GITOPS_ACC_VALUES_FILE:-k8s/openstad/environments/acc.values.yaml}
- GITOPS_PROD_VALUES_FILE=${GITOPS_PROD_VALUES_FILE:-k8s/openstad/environments/prod.values.yaml}

- GIT_USER_EMAIL="travis@travis-ci.org"
- GIT_USER_NAME="Travis CI"

# Kube deploy variables
- K8S_DEPLOYMENT_NAME=openstad-frontend
- K8S_NAMESPACE=openstad
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased
* Make image size configurable for the image widget
* Fix HTML injection in search form in the resource overview widget
* Add a new text style to select in the rich text editor.
* Make autoCenter configurable in idea-map-widgets

## 1.0.0
* Add submission to resource form with configurable confirmation settings
* Update ideas-on-map config to work with react-leaflet
Expand Down
9 changes: 9 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

sleep 15
mongo default --eval 'db.createUser({user:"ci",pwd:"test",roles:["readWrite"]});'
npm install --production
npm run test -- --coverage
mkdir assets
NODE_ENV=production APOS_MINIFY=1 APOS_WORKFLOW=ON APOS_BUNDLE=assets node apostrophe.js apostrophe:generation --create-bundle assets
docker build -t ${IMAGE_TAG} .
4 changes: 2 additions & 2 deletions gitops_push
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ echo "DOCKER PUSH TAG"
echo ${IMAGE_TAG}
docker push ${IMAGE_TAG}

git config --global user.email "travis@travis-ci.org"
git config --global user.name "Travis CI"
git config --global user.email ${GIT_USER_EMAIL}
git config --global user.name ${GIT_USER_NAME}

git clone ${HELM_REPO} && cd ${HELM_REPO_NAME} && \

Expand Down
2 changes: 1 addition & 1 deletion packages/cms/config/siteConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ module.exports = {
httpOnly: true,
secure: process.env.COOKIE_SECURE_OFF === 'yes' ? false : true,
// Default login lifetime between requests is one day
maxAge: process.env.COOKIE_MAX_AGE || 86400000
maxAge: parseInt(process.env.COOKIE_MAX_AGE) && ! isNaN(parseInt(process.env.COOKIE_MAX_AGE)) ? parseInt(process.env.COOKIE_MAX_AGE) : 86400000
}
},
csrf: {
Expand Down
14 changes: 12 additions & 2 deletions packages/cms/lib/modules/choices-guide-result-widgets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,28 @@ module.exports = {

const superLoad = self.load;
self.load = function(req, widgets, next) {
let apiUrl = self.apos.settings.getOption(req, 'apiUrl')

widgets.forEach((widget) => {

let apiUrl = self.apos.settings.getOption(req, 'apiUrl')
let config = createConfig({
widget: widget,
data: req.data,
jwt: req.session.jwt,
apiUrl: apiUrl,
logoutUrl: apiUrl + '/oauth/logout',
loginUrl: req.data.siteUrl + '/oauth/login?returnTo=' + encodeURIComponent(req.url)
});
widget.config = config;
widget.divId = widget.config.divId;
});

widget.openstadComponentsCdn = (req && req.data && req.data.global && req.data.global.openstadComponentsUrl) || self.apos.settings.getOption(req, 'siteConfig').openstadComponentsCdn;

const containerId = self.apos.utils.generateId();
widget.containerId = containerId;
widget.cssHelperClassesString = widget.cssHelperClasses ? widget.cssHelperClasses.join(' ') : '';
widget.formattedContainerStyles = styleSchema.format(containerId, widget.containerStyles);
});

return superLoad(req, widgets, next);
next();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function createConfig({ widget, data, logoutUrl }) {
module.exports = function createConfig({ widget, data, logoutUrl, loginUrl, jwt, apiUrl }) {

let requireLoginSettings;
requireLoginSettings = {};
Expand All @@ -16,6 +16,16 @@ module.exports = function createConfig({ widget, data, logoutUrl }) {

divId: 'ocs-choices-guide-result-' + parseInt(Math.random() * 1000000).toString(),

siteId: data.global.siteId,
api: {
url: apiUrl,
headers: jwt ? { 'X-Authorization': 'Bearer ' + jwt } : {},
isUserLoggedIn: data.loggedIn,
},
user: {
role: data.openstadUser && data.openstadUser.role,
displayName: data.openstadUser && data.openstadUser.displayName,
},
choicesGuideId: widget.choicesGuideId,
questionGroupId: widget.questionGroupId,
startWithAllQuestionsAnswered: widget.startWithAllQuestionsAnswered,
Expand All @@ -30,6 +40,7 @@ module.exports = function createConfig({ widget, data, logoutUrl }) {
maxLabel: widget.choicesMaxLabel,
withPercentage: widget.choicesWithPercentage,
},
loginUrl,
logoutUrl,
moreInfoUrl: widget.moreInfoUrl && data.siteUrl + widget.moreInfoUrl,
moreInfoLabel: widget.moreInfoLabel,
Expand Down
11 changes: 10 additions & 1 deletion packages/cms/lib/modules/choices-guide-widgets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,19 @@ module.exports = {
let config = createConfig({
widget: widget,
data: req.data,
jwt: req.session.jwt,
apiUrl: self.apos.settings.getOption(req, 'apiUrl')
});
widget.config = config;
widget.divId = widget.config.divId;
});

widget.openstadComponentsCdn = (req && req.data && req.data.global && req.data.global.openstadComponentsUrl) || self.apos.settings.getOption(req, 'siteConfig').openstadComponentsCdn;

const containerId = self.apos.utils.generateId();
widget.containerId = containerId;
widget.cssHelperClassesString = widget.cssHelperClasses ? widget.cssHelperClasses.join(' ') : '';
widget.formattedContainerStyles = styleSchema.format(containerId, widget.containerStyles);
});

return superLoad(req, widgets, next);
next();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
module.exports = function createConfig({ widget, data }) {
module.exports = function createConfig({ widget, data, jwt, apiUrl }) {

let config = {

divId: 'ocs-choices-guide-' + parseInt(Math.random() * 1000000).toString(),

siteId: data.global.siteId,
api: {
url: apiUrl,
headers: jwt ? { 'X-Authorization': 'Bearer ' + jwt } : {},
isUserLoggedIn: data.loggedIn,
},
user: {
role: data.openstadUser && data.openstadUser.role,
displayName: data.openstadUser && data.openstadUser.displayName,
},
choicesGuideId: widget.choicesGuideId,

noOfQuestionsToShow: widget.noOfQuestionsToShow,
Expand All @@ -24,7 +33,13 @@ module.exports = function createConfig({ widget, data }) {
beforeUrl: widget.beforeUrl && data.siteUrl + widget.beforeUrl,
afterUrl: widget.afterUrl && data.siteUrl + widget.afterUrl,
image: {
server: {
process: '/image',
fetch: '/image',
srcExtension: '/:/rs=w:[[width]],h:[[height]];cp=w:[[width]],h:[[height]]',
},
aspectRatio: widget.imageAspectRatio || '16x9',
allowMultipleImages: false,
},
}

Expand Down
14 changes: 14 additions & 0 deletions packages/cms/lib/modules/ideas-on-map-widgets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,30 @@ module.exports = {

const superLoad = self.load;
self.load = function(req, widgets, next) {
const siteUrl = self.apos.settings.getOption(req, 'siteUrl');
let imageProxy = siteUrl + '/image';

widgets.forEach((widget) => {

let config = createConfig({
widget: widget,
data: req.data,
apos: self.apos,
jwt: req.session.jwt,
apiUrl: self.apos.settings.getOption(req, 'apiUrl'),
imageProxy,
loginUrl: req.data.siteUrl + '/oauth/login?{returnTo}'
});
widget.config = config;
widget.divId = widget.config.divId;

widget.openstadComponentsCdn = (req && req.data && req.data.global && req.data.global.openstadComponentsUrl) || self.apos.settings.getOption(req, 'siteConfig').openstadComponentsCdn;

const containerId = self.apos.utils.generateId();
widget.containerId = containerId;
widget.cssHelperClassesString = widget.cssHelperClasses ? widget.cssHelperClasses.join(' ') : '';
widget.formattedContainerStyles = styleSchema.format(containerId, widget.containerStyles);

});

return superLoad(req, widgets, next);
Expand Down
23 changes: 19 additions & 4 deletions packages/cms/lib/modules/ideas-on-map-widgets/lib/create-config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const sortingOptions = require('../../../../config/sorting.js').ideasOnMapOptions;
const ideaForm = require('./idea-form');

module.exports = function createConfig({ widget, data, apos }) {
module.exports = function createConfig({ widget, data, apos, jwt, apiUrl, loginUrl, imageProxy }) {

let contentConfig = {
ignoreReactionsForIdeaIds: widget.ignoreReactionsForIdeaIds,
Expand Down Expand Up @@ -43,7 +43,16 @@ module.exports = function createConfig({ widget, data, apos }) {
let config = {

divId: 'ocs-component-ideas-on-map-' + parseInt(Math.random() * 1000000).toString(),

siteId: data.global.siteId,
api: {
url: apiUrl,
headers: jwt ? { 'X-Authorization': 'Bearer ' + jwt } : [],
isUserLoggedIn: data.loggedIn,
},
user: {
role: data.openstadUser && data.openstadUser.role,
displayName: data.openstadUser && data.openstadUser.displayName,
},
display: {
type: widget.displayType,
width: widget.displayWidth,
Expand All @@ -53,7 +62,8 @@ module.exports = function createConfig({ widget, data, apos }) {
canSelectLocation: widget.canSelectLocation,
onMarkerClickAction: widget.onMarkerClickAction,
startWithListOpenOnMobile: widget.startWithListOpenOnMobile,


loginUrl,
linkToCompleteUrl: widget.linkToCompleteUrl && data.siteUrl + widget.linkToCompleteUrl,
linkToUserPageUrl: widget.linkToUserPageUrl && data.siteUrl + widget.linkToUserPageUrl,

Expand Down Expand Up @@ -84,8 +94,13 @@ module.exports = function createConfig({ widget, data, apos }) {
showSortButton: widget.selectedSorting && widget.selectedSorting.length ? true : false,
defaultValue: widget.defaultSorting,
},

image: {
server: {
process: imageProxy,
fetch: imageProxy,
srcExtension: '/:/rs=w:[[width]],h:[[height]];cp=w:[[width]],h:[[height]]',
},
aspectRatio: widget.imageAspectRatio || '16x9',
allowMultipleImages,
placeholderImageSrc,
Expand Down
34 changes: 33 additions & 1 deletion packages/cms/lib/modules/image-widgets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,38 @@ module.exports = {
label: 'Textual alternative',
type: 'string'
},
{
name: 'displaySize',
type: 'select',
label: 'Display size',
def: 'full',
choices: [
{
value: 'max',
label: "Max (1600x1600)"
},
{
value: 'full',
label: "Volledig (1140x1140)",
},
{
value: 'two-thirds',
label: "Medium-groot (760x760)",
},
{
value: 'one-half',
label: "Medium (570x700)",
},
{
value: 'one-third',
label: "Medium-klein (380x700)",
},
{
value: 'one-sixth',
label: "Klein (190x350)",
},
]
},
styleSchema.definition('imageStyles', 'Styles for the image'),

],
Expand All @@ -36,7 +68,7 @@ module.exports = {
{
name: 'generalGroup',
label: 'General',
fields: ['uploadedImage']
fields: ['uploadedImage', 'displaySize']
},
{
name: 'stylingGroup',
Expand Down

1 comment on commit a5d38ed

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Published new image: openstad/frontend:feature-allow-component-url-to-be-set-per-site-ams-a5d38ed

Please sign in to comment.