Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fpesch committed Sep 12, 2021
0 parents commit 9176a0a
Show file tree
Hide file tree
Showing 27 changed files with 375 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/src/Resources/public/
/node_modules/
/vendor/
16 changes: 16 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
'env': {
'browser': true,
'es2021': true,
},
'extends': [
'google',
],
'parserOptions': {
'ecmaVersion': 12,
'sourceType': 'module',
},
'rules': {
'require-jsdoc': 0,
},
};
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/.github/ export-ignore
/.eslintignore export-ignore
/.eslintrc.js export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/package.json export-ignore
/README.md export-ignore
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/ @bpesch
13 changes: 13 additions & 0 deletions .github/workflows/greetings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Greetings

on: [ pull_request, issues ]

jobs:
greeting:
runs-on: ubuntu-latest
steps:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: '🥳 Congratulations on creating your first issue!'
pr-message: '🥳 Congratulations on creating your first pull request!'
35 changes: 35 additions & 0 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Quality analysis

on: [ push ]

jobs:
composer_normalize:
name: composer.json normalizer
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: gd

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

- name: Install dependencies
run: make install

- name: composer normalize
run: composer normalize --dry-run

eslint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install modules
run: npm install

- name: Run ESLint
run: npx eslint ./
36 changes: 36 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release Plugin

on:
push:
tags:
- '*'

env:
PLUGIN_NAME: ${{ github.event.repository.name }}
PLUGIN_UPLOADER_VERSION: 0.3.16

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v2
with:
path: ${{ env.PLUGIN_NAME }}

- name: Fix permissions
run: mkdir $(pwd)/${PLUGIN_NAME}/src/Resources/public && chmod -R 777 $(pwd)/${PLUGIN_NAME}/src/Resources/public

- name: Build JavaScript
run: sudo docker run --rm -e BUILD_PLUGIN=${PLUGIN_NAME} -v $(pwd)/${PLUGIN_NAME}:/var/www/html/custom/plugins/${PLUGIN_NAME} dockware/dev:latest

- name: Install Plugin Uploader
run: wget 'https://github.com/FriendsOfShopware/FroshPluginUploader/releases/download/${{ env.PLUGIN_UPLOADER_VERSION }}/frosh-plugin-upload.phar' -O frosh-plugin-upload.phar

- name: Build Zip
run: php frosh-plugin-upload.phar ext:zip ${PLUGIN_NAME}

- name: Release
uses: softprops/action-gh-release@v1
with:
files: ${{ env.PLUGIN_NAME }}*.zip
20 changes: 20 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Mark stale issues and pull requests

on:
schedule:
- cron: "30 1 * * *"

jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Stale issue message'
stale-pr-message: 'Stale pull request message'
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/node_modules/
/vendor/
/src/Resources/public/
/composer.lock
/package-lock.json
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 bpesch

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.DEFAULT_GOAL := help

.PHONY: help
help: ## display command overview
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[35m%-30s\033[0m %s\n", $$1, $$2}'

install: ## install dependencies
composer update --no-interaction --no-progress --no-ansi
npm install

clean: ## cleanup installed dependencies and lockfiles
rm -rf composer.lock
rm -rf vendor
rm -rf package-lock.json
rm -rf node_modules

.PHONY: cs
cs: ## enforce code style
npx eslint --fix ./
composer normalize
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<h1 align="center">
<img src="assets/logo.svg" width="512px">
</h1>

# Dashboard Joke

Lighten up your work day with a fresh joke every time you open the dashboard!

<img src="assets/joke.png" width="512px">

## Usage requirements

<p float="left">
<a href="http://shopware.com"><img src="assets/shopware.png" alt="shopware" width="32"/></a>
</p>

## Development requirements

<p float="left">
<a href="https://git-scm.com"><img src="assets/git.png" alt="git" width="32"/></a>
<a href="https://cmake.org"><img src="assets/cmake.png" alt="cmake" width="32"/></a>
<a href="https://www.docker.com"><img src="assets/docker.png" alt="docker" width="32"/></a>
</p>

## Usage

Install and activate the plugin in your Shopware instance.

```
composer require family-office/dashboard-joke
```

```
bin/console plugin:refresh && bin/console plugin:install FamilyOfficeDashboardJoke --activate
```

The only thing that's left to do for the plugin to work is to link your shops hidden service via the plugin configuration.

## Development

Clone the project into your Shopware installation

```shell
git clone git@github.com:Family-Office-Company/FamilyOfficeDashboardJoke.git
```

```shell
cd FamilyOfficeDashboardJoke
```

Install the development dependencies

```shell
make install
```

..and start developing! 🥳

## Acknowledgements

Thanks to [Freepik](https://www.freepik.com) from [www.flaticon.com](https://www.flaticon.com/)
for providing the plugin icon.

We also thank [jokeapi.dev](https://jokeapi.dev) for providing the jokes via an easy-to-use REST API.

## License

This project is licensed under the [MIT](LICENSE) license.
Feel free to do whatever you want with the code!
Binary file added assets/cmake.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/docker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/git.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/joke.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shopware.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "family-office/dashboard-joke",
"type": "shopware-platform-plugin",
"description": "Displays a random joke on Shopware 6's administration dashboard.",
"keywords": [
"shopware-platform-plugin",
"jokes",
"dashboard"
],
"homepage": "https://github.com/Family-Office-Company/FamilyOfficeDashboardJoke",
"readme": "README.md",
"version": "1.0.0",
"license": "MIT",
"authors": [
{
"name": "Family Office",
"email": "contact@family-office.holdings",
"homepage": "https://github.com/Family-Office-Company",
"role": "Manufacturer"
}
],
"require": {
"shopware/storefront": "^6.4"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.15",
"roave/security-advisories": "dev-latest"
},
"extra": {
"description": {
"de-DE": "Displays a random joke on Shopware 6's administration dashboard.",
"en-GB": "Displays a random joke on Shopware 6's administration dashboard."
},
"label": {
"de-DE": "Dashboard Witz",
"en-GB": "Dashboard Joke"
},
"manufacturerLink": {
"de-DE": "https://github.com/Family-Office-Company",
"en-GB": "https://github.com/Family-Office-Company"
},
"shopware-plugin-class": "FamilyOffice\\DashboardJoke\\FamilyOfficeDashboardJoke"
},
"autoload": {
"psr-4": {
"FamilyOffice\\DashboardJoke\\": "src/"
}
},
"support": {
"issues": "https://github.com/Family-Office-Company/FamilyOfficeDashboardJoke/issues"
}
}
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"devDependencies": {
"eslint": "^7.32.0",
"eslint-config-google": "^0.14.0"
}
}
11 changes: 11 additions & 0 deletions src/FamilyOfficeDashboardJoke.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

namespace FamilyOffice\DashboardJoke;

use Shopware\Core\Framework\Plugin;

final class FamilyOfficeDashboardJoke extends Plugin
{
}
2 changes: 2 additions & 0 deletions src/Resources/app/administration/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import './module/sw-dashboard/page/sw-dashboard-index';
import './service/jokeClient.service';
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import template from './sw-dashboard-index.html.twig';

Shopware.Component.override('sw-dashboard-index', {
template,

inject: ['jokeClient'],

data() {
return {
joke: null,
};
},

methods: {
createdComponent() {
this.fetchJoke();
this.$super('createdComponent');
},

fetchJoke() {
this.jokeClient.getJoke().then((joke) => {
this.joke = joke;
});
},
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% block sw_dashboard_index_content_intro_welcome_message %}
<p class="sw-dashboard-index__welcome-message">
{{ joke.setup }}
<br>
{{ joke.delivery }}
</p>
{% endblock %}
16 changes: 16 additions & 0 deletions src/Resources/app/administration/src/service/jokeClient.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const ApiService = Shopware.Classes.ApiService;

class JokeClient extends ApiService {
getJoke() {
return this.httpClient.get(
'https://v2.jokeapi.dev/joke/Any?blacklistFlags=nsfw,religious,political,racist,sexist,explicit',
).then((response) => {
return ApiService.handleResponse(response);
});
}
}

Shopware.Application.addServiceProvider('jokeClient', (container) => {
const initContainer = Shopware.Application.getContainer('init');
return new JokeClient(initContainer.httpClient, container.loginService);
});
Binary file added src/Resources/config/plugin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
</services>
</container>

0 comments on commit 9176a0a

Please sign in to comment.