-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0d2741f
Showing
210 changed files
with
39,329 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["@babel/preset-env"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
last 2 versions | ||
>0.1% | ||
Firefox ESR | ||
not ie 10 | ||
not ie_mob 10 | ||
# not ie 11 # we want IE 11 for now | ||
not op_mini all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
name: hb | ||
on: [push] | ||
jobs: | ||
build_backend: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.0' | ||
env: | ||
fail-fast: true | ||
|
||
- name: Install deps | ||
run: composer install --ansi | ||
|
||
# - name: Run phpstan | ||
# run: composer phpstan | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: backend-deps | ||
path: vendor | ||
|
||
build_frontend: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18.x | ||
|
||
- name: Install external deps | ||
run: sudo apt-get update && sudo apt-get install -y pngquant imagemagick | ||
|
||
- name: Install deps | ||
uses: borales/actions-yarn@v5 | ||
with: | ||
cmd: install | ||
|
||
- name: Build deps | ||
uses: borales/actions-yarn@v5 | ||
with: | ||
cmd: build | ||
env: | ||
NODE_ENV: production | ||
|
||
- name: Build hb-events | ||
working-directory: ./hb-events | ||
run: | | ||
yarn install | ||
yarn build | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: frontend-deps | ||
path: | | ||
UI/AboutStructure/assets/dist | ||
UI/Contacts/assets/dist | ||
UI/Event/assets/dist | ||
UI/Rentals/assets/dist | ||
frontend/dist | ||
hb-events/build | ||
pack: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build_backend | ||
- build_frontend | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Download backend artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: backend-deps | ||
|
||
- name: Download frontend artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: frontend-deps | ||
|
||
- name: Pack files for release | ||
run: | | ||
zip -r brontosaurus-theme.zip . \ | ||
-i "config/*" \ | ||
-i "CoordinatesResolver/*" \ | ||
-i "DataContainers/*" \ | ||
-i "Filters/*" \ | ||
-i "frontend/*" \ | ||
-x "frontend/src/*" \ | ||
-i "hb-events/*" \ | ||
-x "hb-events/src/*" \ | ||
-i "images/*" \ | ||
-i "log/*" \ | ||
-i "Rewrites/*" \ | ||
-i "scripts/*" \ | ||
-i "template-parts/*" \ | ||
-i "vendor/*" \ | ||
-i "webfonts/*" \ | ||
-i "Assets.php" \ | ||
-i "archive-novinky.php" \ | ||
-i "bootstrap.php" \ | ||
-i "composer.json" \ | ||
-i "composer.lock" \ | ||
-i "Configuration.php" \ | ||
-i "Container.php" \ | ||
-i "exceptions.php" \ | ||
-i "footer.php" \ | ||
-i "functions.php" \ | ||
-i "header.php" \ | ||
-i "helpers.php" \ | ||
-i "homepage-banner.php" \ | ||
-i "index.php" \ | ||
-i "PostTypeInitializer.php" \ | ||
-i "screenshot.png" \ | ||
-i "single-novinky.php" \ | ||
-i "style.css" | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: deps | ||
path: brontosaurus-theme.zip | ||
|
||
deploy_staging: | ||
runs-on: ubuntu-latest | ||
if: ${{ ! startsWith(github.ref_name, 'dependabot') }} | ||
needs: pack | ||
environment: | ||
name: staging | ||
url: https://dev.brontosaurus.cz | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Download artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: deps | ||
|
||
- name: Extract files to deploy | ||
run: | | ||
mkdir -p deploy/files | ||
unzip brontosaurus-theme.zip -d deploy/files | ||
- name: Set up SSH connection | ||
run: | | ||
mkdir -p ~/.ssh | ||
echo "${{ secrets.SERVER_KEYSCAN }}" > ~/.ssh/known_hosts | ||
echo "${{ secrets.KEY_PRIVATE }}" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa | ||
echo "${{ secrets.KEY_PUBLIC }}" > ~/.ssh/id_rsa.pub | ||
- name: Deploy | ||
run: | | ||
bash deploy/deploy.sh ${{ secrets.STAGING_REMOTE_USER_AND_HOST }}:${{ secrets.STAGING_REMOTE_PROJECT_DIR }}/wp-content/themes/brontosaurus-theme | ||
ssh ${{ secrets.STAGING_REMOTE_USER_AND_HOST }} "rm -rf ${{ secrets.STAGING_REMOTE_PROJECT_DIR }}/wp-content/themes/brontosaurus-theme/temp/cache" | ||
deploy_production: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.ref_name == 'main' }} | ||
needs: pack | ||
environment: | ||
name: production | ||
url: https://brontosaurus.cz | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Download artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: deps | ||
|
||
- name: Extract files to deploy | ||
run: | | ||
mkdir -p deploy/files | ||
unzip brontosaurus-theme.zip -d deploy/files | ||
- name: Set up SSH connection | ||
run: | | ||
mkdir -p ~/.ssh | ||
echo "${{ secrets.SERVER_KEYSCAN }}" > ~/.ssh/known_hosts | ||
echo "${{ secrets.KEY_PRIVATE }}" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa | ||
echo "${{ secrets.KEY_PUBLIC }}" > ~/.ssh/id_rsa.pub | ||
- name: Deploy | ||
run: | | ||
bash deploy/deploy.sh ${{ secrets.PRODUCTION_REMOTE_USER_AND_HOST }}:${{ secrets.PRODUCTION_REMOTE_PROJECT_DIR }}/wp-content/themes/brontosaurus-theme | ||
ssh ${{ secrets.PRODUCTION_REMOTE_USER_AND_HOST }} "rm -rf ${{ secrets.PRODUCTION_REMOTE_PROJECT_DIR }}/wp-content/themes/brontosaurus-theme/temp/cache" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace HnutiBrontosaurus\Theme; | ||
|
||
use WP_Theme; | ||
use function filemtime; | ||
use function sprintf; | ||
use function wp_enqueue_script; | ||
use function wp_enqueue_style; | ||
|
||
|
||
final class Assets | ||
{ | ||
|
||
public static function script(string $name, WP_Theme $theme): void | ||
{ | ||
wp_enqueue_script( | ||
handle: 'hb-' . $name, | ||
src: self::src($name, self::JS_PATTERN, $theme), | ||
ver: self::ver($name, self::JS_PATTERN, $theme), | ||
); | ||
} | ||
|
||
public static function staticScript(string $name, WP_Theme $theme): void | ||
{ | ||
wp_enqueue_script( | ||
handle: 'hb-' . $name, | ||
src: self::src($name, self::STATIC_JS_PATTERN, $theme), | ||
ver: self::ver($name, self::STATIC_JS_PATTERN, $theme), | ||
); | ||
} | ||
|
||
public static function style(string $name, WP_Theme $theme): void | ||
{ | ||
wp_enqueue_style( | ||
handle: 'hb-' . $name, | ||
src: self::src($name, self::CSS_PATTERN, $theme), | ||
ver: self::ver($name, self::CSS_PATTERN, $theme), | ||
); | ||
} | ||
|
||
private const CSS_PATTERN = '%s/frontend/dist/css/%s.css'; | ||
private const JS_PATTERN = '%s/frontend/dist/js/%s.js'; | ||
private const STATIC_JS_PATTERN = '%s/scripts/%s.js'; | ||
|
||
private static function src(string $for, string $pattern, WP_Theme $theme): string | ||
{ | ||
return sprintf($pattern, $theme->get_template_directory_uri(), $for); | ||
} | ||
|
||
private static function ver(string $for, string $pattern, WP_Theme $theme): int | ||
{ | ||
$path = sprintf($pattern, $theme->get_template_directory(), $for); | ||
return filemtime($path); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace HnutiBrontosaurus\Theme; | ||
|
||
use Nette\Neon\Neon; | ||
|
||
|
||
final class Configuration | ||
{ | ||
private const ROOT_KEY_PARAMETERS = 'parameters'; | ||
|
||
private array $configuration = []; | ||
|
||
/** | ||
* @throws \Exception | ||
*/ | ||
public function __construct(array $configFiles) | ||
{ | ||
foreach ($configFiles as $file) { | ||
if (!\file_exists($file)) { | ||
throw new \Exception('Config file `' . $file . '` does not exist.'); | ||
} | ||
|
||
$fileContent = \file_get_contents($file); | ||
$configuration = Neon::decode($fileContent); | ||
|
||
if (!\array_key_exists(self::ROOT_KEY_PARAMETERS, $configuration)) { | ||
throw new \Exception('Only `' . self::ROOT_KEY_PARAMETERS . '` root key is supported in config files.'); | ||
} | ||
|
||
$this->configuration = \array_merge($this->configuration, $configuration[self::ROOT_KEY_PARAMETERS]); | ||
} | ||
} | ||
|
||
|
||
public function has(string $name): bool | ||
{ | ||
try { | ||
$this->get($name); | ||
return true; | ||
|
||
} catch (\Exception) { | ||
return false; | ||
} | ||
} | ||
|
||
|
||
/** | ||
* Gets single item of configuration. You can use `:` separator to target nested keys. | ||
* @throws \Exception | ||
*/ | ||
public function get(string $name): mixed | ||
{ | ||
$keyList = \explode(':', $name); | ||
$currentDimension = $this->configuration; | ||
foreach ($keyList as $key) { | ||
if (!\array_key_exists($key, $currentDimension)) { | ||
throw new \Exception('Key `' . $name . '` was not found in configuration.'); | ||
} | ||
|
||
$value = $currentDimension[$key]; | ||
$currentDimension = $currentDimension[$key]; | ||
} | ||
|
||
return $value; | ||
} | ||
|
||
|
||
public function getAll(): array | ||
{ | ||
return $this->configuration; | ||
} | ||
|
||
} |
Oops, something went wrong.