diff --git a/.env b/.env index f892ecbb..e96a94ad 100644 --- a/.env +++ b/.env @@ -23,6 +23,10 @@ APP_BUILD=dev # The description for this api APP_DESCRIPTION='Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar.' + +APP_LOGO=pc.zaakonline.nl +APP_HOME=pc.zaakonline.nl + # The urls on wich this api is available TRUSTED_PROXIES=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 TRUSTED_HOSTS=^(.+\.)?conduction\.nl$|^(.+\.)?vng\.cloud$|^(.+\.)?huwelijksplanner\.online$|^(.+\.)?larping\.eu$|^(.+\.)?common-ground\.dev$|^(.+\.)?trouwplanner\.online$|^(.+\.)?zaakonline\.nl$|localhost diff --git a/AUTHORS.md b/AUTHORS.md new file mode 100644 index 00000000..11794373 --- /dev/null +++ b/AUTHORS.md @@ -0,0 +1 @@ +# AUTHORS diff --git a/ROADMAP.md b/ROADMAP.md new file mode 100644 index 00000000..437766dd --- /dev/null +++ b/ROADMAP.md @@ -0,0 +1 @@ +# Roadmap diff --git a/TUTORIAL.md b/TUTORIAL.md index 356121e3..56565e51 100644 --- a/TUTORIAL.md +++ b/TUTORIAL.md @@ -306,15 +306,9 @@ More information on using data fixtures can be found at the [symfony website](ht ## Sharing your work A vital part of te common ground community is sharing your work, and telling other people what you are working. This way people can help you with problems that you run into. And keep tabs on any (security) updates that you make to you code. Sounds like a lot of work right? -Wel it actually isn't, there is a specific common ground platform over at common-ground.dev that reads repositories and updates user. So the only thing we need to do is tell this platform that we have started a new common ground repository. And tell it when we have updates ours. We can do all that by simply adding a webhook to our component. +Wel it actually isn't, there is a specific common ground platform over at common-ground.dev that reads repositories and updates user. So the only thing we need to do is tell this platform that we have started a new common ground repository. How do we do that? Simple we use the name common ground (or commonground) in the discription of our repository. common-ground.dev should then pick up our repository within the hour. -When using Github. To set up a webhook, go to the settings page of your repository or organization. From there, click Webhooks, then Add webhook. Use te following settings: -* Payload URL: https://www.common-ground.dev/webhook/github -* Content type: Application/JSON -* Secret: [leave blanck] -* Events: [just the push event] - -Now every time you update your repository the commonground dev page will alerted, rescan your repository and do al the appropriate platform actions. It just as easy as that. +Another option that we have is to declare our repository on [publiccode](), to do this you need to copy the publiccode.yaml from the [api/public/schema](api/public/schema]) folder to your root folder (dont forget to redo this every time you make a change to your repository). Continues integration diff --git a/api/Dockerfile b/api/Dockerfile index c48a7b4b..24fae412 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -118,6 +118,8 @@ CMD ["php-fpm"] # Let update the docs to show the latest chages # RUN bin/console api:swagger:export --output=/srv/api/public/schema/openapi.yaml --yaml --spec-version=3 +RUN bin/console app:publiccode:update --location=/srv/api/public/schema/ --spec-version=0.2 + ############################# # "nginx" stage # ############################# diff --git a/api/config/packages/api_platform.yaml b/api/config/packages/api_platform.yaml index 6624d8ab..58417518 100644 --- a/api/config/packages/api_platform.yaml +++ b/api/config/packages/api_platform.yaml @@ -20,7 +20,7 @@ parameters: env(CONTAINER_PROJECT_NAME): '' env(CONTAINER_REPRO): '' -api_platform: +api_platform: mapping: paths: ['%kernel.project_dir%/src/Entity'] diff --git a/api/config/packages/doctrine.yaml b/api/config/packages/doctrine.yaml index b935c8e3..dae8287b 100644 --- a/api/config/packages/doctrine.yaml +++ b/api/config/packages/doctrine.yaml @@ -1,3 +1,7 @@ +parameters: + env(DATABASE_URL): 'postgres://api-platform:!ChangeMe!@db/api?serverVersion=10.1' + # Organisation stuff + doctrine: dbal: # configure these for your database server diff --git a/api/config/packages/twig.yaml b/api/config/packages/twig.yaml index 481428f9..0f182e22 100644 --- a/api/config/packages/twig.yaml +++ b/api/config/packages/twig.yaml @@ -1,12 +1,35 @@ parameters: - env(APP_DOMAINS): '[]' # Organisation stuff + env(GOOGLE_TAG_MANAGER_ID): '' + env(HUBSPOT_EMBED_CODE): '' + env(CONTAINER_REGISTRY_BASE): '' + env(CONTAINER_PROJECT_NAME): '' env(ORGANIZATION_NAME): '' - env(ORGANIZATION_EMAIL_ADDRESS): '' - env(ORGANIZATION_COUNTRY_NAME): '' - env(ORGANIZATION_STATE): '' - env(ORGANIZATION_LOCALITY): '' + env(ORGANIZATION_EMAIL_ADDRESS): '' + env(ORGANIZATION_COUNTRY_NAME): '' + env(ORGANIZATION_STATE): '' + env(ORGANIZATION_LOCALITY): '' env(ORGANIZATION_UNIT_NAME): '' + env(APP_NAME): '' + env(APP_TITLE): '' + env(APP_LOGO): '' + env(APP_HOME): '' + env(APP_VERSION): '' + env(APP_ENV): '' + env(APP_DEBUG): '' + env(APP_SUBDOMAIN): '' + env(APP_DOMAINS): '[]' + env(APP_DEMO): '' + env(APP_REPRO): '' + env(APP_DESCRIPTION): '' + env(AUTH_ENABLED): '' + env(AUDITTRAIL_ENABLED): '' + env(NOTIFICATION_ENABLED): '' + env(HEALTH_ENABLED): '' + env(TRUSTED_HOSTS): '' + env(TRUSTED_PROXIES): '' + env(NLX_OUTWAY): '' + env(NLX_INWAY): '' twig: default_path: '%kernel.project_dir%/templates' @@ -28,6 +51,8 @@ twig: app_name: '%env(APP_NAME)%' app_title: '%env(APP_TITLE)%' + app_logo: '%env(APP_LOGO)%' + app_home: '%env(APP_HOME)%' app_version: '%env(APP_VERSION)%' app_env: '%env(APP_ENV)%' app_debug: '%env(APP_DEBUG)%' diff --git a/api/docker/php/docker-entrypoint.sh b/api/docker/php/docker-entrypoint.sh index 54b7c9e8..59e902c4 100755 --- a/api/docker/php/docker-entrypoint.sh +++ b/api/docker/php/docker-entrypoint.sh @@ -69,7 +69,11 @@ if [ "$1" = 'php-fpm' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then # this should only be done in an build echo "Updating Helm charts" - bin/console app:helm:update --location=/srv/api/helm --spec-version=3 + bin/console app:helm:update --location=/srv/api/helm --spec-version=3 + + # this should only be done in an build + echo "Updating publiccode charts" + bin/console app:publiccode:update --location=/srv/api/public/schema/ --spec-version=0.2 fi fi diff --git a/api/helm/Chart.yaml b/api/helm/Chart.yaml index 7c3c8a6a..22911f7f 100644 --- a/api/helm/Chart.yaml +++ b/api/helm/Chart.yaml @@ -3,5 +3,5 @@ appVersion: V.0.1 description: ''Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar.'' name: pc version: 0.1.0 -home: https://common-ground.dev -icon: https://common-ground.dev/logo-250x250.png \ No newline at end of file +home: pc.zaakonline.nl +icon: pc.zaakonline.nl \ No newline at end of file diff --git a/api/public/schema/publiccode.yaml b/api/public/schema/publiccode.yaml new file mode 100644 index 00000000..1f17c57e --- /dev/null +++ b/api/public/schema/publiccode.yaml @@ -0,0 +1,115 @@ +publiccodeYmlVersion: "0.2" + +name: pc +applicationSuite: commonground +url: "https://github.com/ConductionNL/Proto-component-commonground" +landingURL: "pc.zaakonline.nl" +isBasedOn: "https://github.com/ConductionNL/Proto-component-commonground.git" softwareVersion: "V.0.1" +releaseDate: "2019-28-12" +logo: pc.zaakonline.nl +monochromeLogo: img/logo-mono.svg + +inputTypes: + - application/json + - application/xml + +outputTypes: + - application/json + - application/ld+json + - application/hal+json + - application/vnd.api+json + - application/health+json + - application/xml + - application/x-yaml + - text/csv + - text/html + +platforms: + - web + +categories: + - it-development + +usedBy: + - Gemeente Utrecht + - Gemeente Den Haag + - Gemeente Hoorn + + +roadmap: "https://github.com/ConductionNL/Proto-component-commonground/blob/master/ROADMAP.md" + +developmentStatus: development + +softwareType: "standalone/other" + +#intendedAudience: +# scope: +# - science-and-technology +# countries: +# - it +# - de +# unsupportedCountries: +# - us + +description: + en: +# localisedName: Medusa +# genericName: Text Editor +# shortDescription: > +# This description can have a maximum 150 +# characters long. We should not fill the +# remaining space with "Lorem Ipsum". End +# +# longDescription: > +# Very long description of this software, also split +# on multiple rows. You should note what the software +# is and why one should need it. + + documentation: "https://github.com/ConductionNL/Proto-component-commonground/blob/master/README.md" + apiDocumentation: "pc.zaakonline.nl" +# +# features: +# - Very important feature +# - Will run without a problem +# - Has zero bugs +# - Solves all the problems of the world +# screenshots: +# - img/sshot1.jpg +# - img/sshot2.jpg +# - img/sshot3.jpg +# videos: +# - https://youtube.com/xxxxxxxx +# awards: +# - 1st Price Software of the year + +legal: + license: EUPL-1.2 + mainCopyrightOwner: Conduction + repoOwner: Conduction + authorsFile: AUTHORS.md + +maintenance: + type: "internal" + + contractors: + - name: "Conduction B.V" + email: "info@conduction.nl" + website: "https://www.conduction.nl" + until: "2099-01-01" + + contacts: + - name: Ruben van der Linde + email: "ruben@conduction.nl" + affiliation: "Conduction B.V" + +localisation: + localisationReady: yes + availableLanguages: + - en + - nl + +dependsOn: + open: + - name: Kubernetes + versionMin: "1.15.5-do.1" + diff --git a/api/src/Command/PubliccodeCommand.php b/api/src/Command/PubliccodeCommand.php new file mode 100644 index 00000000..75c24371 --- /dev/null +++ b/api/src/Command/PubliccodeCommand.php @@ -0,0 +1,71 @@ +twig = $twig; + + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('app:publiccode:update') + // the short description shown while running "php bin/console list" + ->setDescription('Creates a new public chart.') + + // the full command description shown when running the command with + // the "--help" option + ->setHelp('see ehttps://github.com/italia/publiccode.yml') + ->setDescription('Publiccode.yml is a metadata standard for repositories containing software developed or acquired by the Public Administration, aimed at making them easily discoverabile and thus reusable by other entities.By including a publiccode.yml file in the root of a repository, and populating it with information about the software, technicians and civil servants can evaluate it. Automatic indexing tools can also be built, since the format is easily readable by both humans and machines.') + ->addOption('location', null, InputOption::VALUE_OPTIONAL, 'Write output to files in the given location', '/srv/api/public/schema/') + ->addOption('spec-version', null, InputOption::VALUE_OPTIONAL, 'Publiccode version to use ("0.1.0")', '0.1.0'); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new SymfonyStyle($input, $output); + /** @var string $version */ + $version = $input->getOption('spec-version'); + + //if (!\in_array($version, ['0.1.0'], true)) { + // throw new InvalidOptionException(sprintf('This tool only supports version 2 and 3 of the OpenAPI specification ("%s" given).', $version)); + //} + + $publiccode = $this->twig->render('publiccode/publiccode.yaml.twig'); + + if (!empty($location = $input->getOption('location')) && \is_string($location)) { + file_put_contents($location.'/publiccode.yaml', $publiccode); + $io->success(sprintf('Data written to %s/publiccode.yaml (specification version %s).', $location, $version)); + } else { + // outputs multiple lines to the console (adding "\n" at the end of each line) + $output->writeln([ + 'Publiccode Chart', + '============', + $chart, + ]); + } + } +} diff --git a/api/src/Subscriber/FieldsAndExtendSubscriber.php b/api/src/Subscriber/FieldsAndExtendSubscriber.php index 22420329..d50440c7 100644 --- a/api/src/Subscriber/FieldsAndExtendSubscriber.php +++ b/api/src/Subscriber/FieldsAndExtendSubscriber.php @@ -33,6 +33,7 @@ public static function getSubscribedEvents() public function FilterFields(GetResponseForControllerResultEvent $event) { + /* @todo Contains a bug $result = $event->getControllerResult(); $fields = $event->getRequest()->query->get('fields'); $extends = $event->getRequest()->query->get('extend'); @@ -41,6 +42,12 @@ public function FilterFields(GetResponseForControllerResultEvent $event) $contentType= $event->getRequest()->headers->get('Accept'); } + + // Only do somthing if fields is query supplied + if (!$fields && !$extends) { + return $result; + } + // This needs to be bassed on the content-type // Lets set a return content type @@ -58,11 +65,6 @@ public function FilterFields(GetResponseForControllerResultEvent $event) $contentType = 'application/json'; $renderType = "json"; } - - // Only do somthing if fields is query supplied - if (!$fields && $extends) { - return $result; - } // let turn fields into an array if it isn't one already if (!is_array($fields)) { @@ -73,7 +75,7 @@ public function FilterFields(GetResponseForControllerResultEvent $event) } // Its possible to nest fields for filterins - foreach($fields as $key->$value){ + foreach($fields as $key=>$value){ // Lets check if the fields contain one or more .'s if (strpos($value, '.') !== false) { // This is where it gets complicated couse it could go on indevinitly @@ -101,9 +103,10 @@ public function FilterFields(GetResponseForControllerResultEvent $event) $jsonArray = json_decode($json, true); + // The we want to extend properties from the extend query foreach($extends as $extend){ - /* @todo add security checks */ + // @todo add security checks // Get new object for the extend $extendObject = $this->propertyAccessor->getValue($result, $extend); // turn to json @@ -117,6 +120,7 @@ public function FilterFields(GetResponseForControllerResultEvent $event) $jsonArray[$extend] = json_decode($extendjson, true); } + $json = json_encode($jsonArray); $response = new Response( @@ -126,5 +130,6 @@ public function FilterFields(GetResponseForControllerResultEvent $event) ); $event->setResponse($response); + */ } } diff --git a/api/templates/helm/Chart.yaml.twig b/api/templates/helm/Chart.yaml.twig index 821c26b2..38f81166 100644 --- a/api/templates/helm/Chart.yaml.twig +++ b/api/templates/helm/Chart.yaml.twig @@ -3,5 +3,5 @@ appVersion: {{ app_version }} description: '{{ app_description }}' name: {{ app_name|replace({' ': ''})|lower }} version: 0.1.0 -home: https://common-ground.dev -icon: https://common-ground.dev/logo-250x250.png \ No newline at end of file +home: {{ app_home }} +icon: {{ app_logo }} \ No newline at end of file diff --git a/api/templates/publiccode/publiccode.yaml.twig b/api/templates/publiccode/publiccode.yaml.twig new file mode 100644 index 00000000..88c1d8d1 --- /dev/null +++ b/api/templates/publiccode/publiccode.yaml.twig @@ -0,0 +1,117 @@ +{# Read https://docs.italia.it/italia/developers-italia/publiccodeyml-en/en/master/schema.core.html for the complete standard#} +publiccodeYmlVersion: "0.2" + +name: {{ app_name }} +applicationSuite: commonground +url: "{{ app_repro }}" +landingURL: "{{ app_demo }}" +isBasedOn: "https://github.com/ConductionNL/Proto-component-commonground.git" {# we asume that everything is based on the proto component #} +softwareVersion: "{{ app_version }}" +releaseDate: "{{ "now"|date("Y-d-m") }}" +logo: {{ app_logo }} +monochromeLogo: img/logo-mono.svg + +inputTypes: + - application/json + - application/xml + +outputTypes: + - application/json + - application/ld+json + - application/hal+json + - application/vnd.api+json + - application/health+json + - application/xml + - application/x-yaml + - text/csv + - text/html + +platforms: + - web + +categories: + - it-development + +usedBy: + - Gemeente Utrecht + - Gemeente Den Haag + - Gemeente Hoorn + + +roadmap: "{{ app_repro }}/blob/master/ROADMAP.md" + +developmentStatus: development + +softwareType: "standalone/other" + +#intendedAudience: +# scope: +# - science-and-technology +# countries: +# - it +# - de +# unsupportedCountries: +# - us + +description: + en: +# localisedName: Medusa +# genericName: Text Editor +# shortDescription: > +# This description can have a maximum 150 +# characters long. We should not fill the +# remaining space with "Lorem Ipsum". End +# +# longDescription: > +# Very long description of this software, also split +# on multiple rows. You should note what the software +# is and why one should need it. + + documentation: "{{ app_repro }}/blob/master/README.md" + apiDocumentation: "{{ app_demo }}" +# +# features: +# - Very important feature +# - Will run without a problem +# - Has zero bugs +# - Solves all the problems of the world +# screenshots: +# - img/sshot1.jpg +# - img/sshot2.jpg +# - img/sshot3.jpg +# videos: +# - https://youtube.com/xxxxxxxx +# awards: +# - 1st Price Software of the year + +legal: + license: EUPL-1.2 + mainCopyrightOwner: Conduction + repoOwner: Conduction + authorsFile: AUTHORS.md + +maintenance: + type: "internal" + + contractors: + - name: "Conduction B.V" + email: "info@conduction.nl" + website: "https://www.conduction.nl" + until: "2099-01-01" + + contacts: + - name: Ruben van der Linde + email: "ruben@conduction.nl" + affiliation: "Conduction B.V" + +localisation: + localisationReady: yes + availableLanguages: + - en + - nl + +dependsOn: + open: + - name: Kubernetes + versionMin: "1.15.5-do.1" + diff --git a/docker-compose.yml b/docker-compose.yml index 671f5c94..c6f6b218 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -41,6 +41,8 @@ services: - APP_DEMO=${APP_DEMO} - APP_REPRO=${APP_REPRO} - APP_DESCRIPTION=${APP_DESCRIPTION} + - APP_LOGO=${APP_LOGO} + - APP_HOME=${APP_HOME} - ORGANIZATION_NAME=${ORGANIZATION_NAME} - ORGANIZATION_EMAIL_ADDRESS=${ORGANIZATION_EMAIL_ADDRESS} - ORGANIZATION_COUNTRY_NAME=${ORGANIZATION_COUNTRY_NAME}