diff --git a/.distignore b/.distignore new file mode 100644 index 0000000..30128dd --- /dev/null +++ b/.distignore @@ -0,0 +1,31 @@ +# A set of files you probably don't want in your WordPress.org distribution +.distignore +.editorconfig +.git +.gitignore +.gitlab-ci.yml +.travis.yml +.DS_Store +Thumbs.db +behat.yml +bin +circle.yml +composer.json +composer.lock +Gruntfile.js +package.json +phpunit.xml +phpunit.xml.dist +multisite.xml +multisite.xml.dist +phpcs.ruleset.xml +LICENSE +wp-cli.local.yml +tests +vendor +node_modules +*.sql +*.tar.gz +*.zip +authors.txt +composer.* diff --git a/.github/workflows/release-handler.yml b/.github/workflows/release-handler.yml new file mode 100644 index 0000000..6ccd91d --- /dev/null +++ b/.github/workflows/release-handler.yml @@ -0,0 +1,46 @@ +name: Release Handler + +# Action runs when a new release is published. +on: + release: + types: [published] + +jobs: + release-new: + name: Issue new release + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build Plugin + run: | + composer install --no-dev --optimize-autoloader + composer run build + + - name: Create release archive + uses: montudor/action-zip@v0.1.0 + with: + args: zip -X -r dist/footnotes-${{ github.event.release.tag_name }}.zip dist + + - name: Upload archive as artifact + uses: actions/upload-artifact@v2 + with: + name: footnotes-${{ github.event.release.tag_name }} + path: dist/footnotes-${{ github.event.release.tag_name }}.zip + + - name: Upload archive to release + uses: JasonEtco/upload-to-release@master + with: + args: dist/footnotes-${{ github.event.release.tag_name }}.zip application/zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + #- name: Deploy release to Wordpress.org + # uses: 10up/action-wordpress-plugin-deploy@stable + # with: + # generate-zip: true + # env: + # SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + # SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} diff --git a/.gitignore b/.gitignore index de46eb3..494168f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .phpdoc/ vendor/ +dist/ *.bak authors.txt diff --git a/README.md b/README.md index f55c285..e24b6ac 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,18 @@ Featured on [wpmudev](http://premium.wpmudev.org/blog/12-surprisingly-useful-wor - You can run either across the entire project by adding the argument `--ignore=*/vendor/*` and targetting the file `./**/*.php` - You may have to enable double-wildcards in your console first (`shopt -s globstar`) +## Building + +1. Run `_tools/build-stylesheets.sh -c` to concatenate stylesheets +1. Manually minify the output files in `css/tmp/`, saving them as `.min.css` files + - The intention is to replace this with automated minification, meaning that + all of these steps can be rolled into a single `build` command. +1. Run `_tools/build-stylesheets.sh -d` to deploy the minified files to `dist/` + - **this will delete any existing `dist/` folder** +1. Run `composer run build` to move over the remaining files to `dist/` + - Currently, the files to include in a distribution are hard-coded in `_tools/build.sh` + - The intention is to replace this with a proper parsing of the `.distignore` file + ## Updating Documentation 1. Install [phpDocumentor](https://phpdoc.org/) diff --git a/_tools/build-stylesheets.sh b/_tools/build-stylesheets.sh new file mode 100755 index 0000000..146db4e --- /dev/null +++ b/_tools/build-stylesheets.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +# Concatenates, minifies (TODO) and deploys stylesheets for distribution. +# +# 12 unified stylesheets are concatenated out of these files: +# - `dev-common.css` +# - `dev-tooltips.css` +# - `dev-tooltips-alternative.css` +# - `dev-layout-reference-container.css` +# - `dev-layout-entry-content.css` +# - `dev-layout-main-content.css` + +echo "Running $(dirname "$0")/build-stylesheets.sh" + +if [[ $1 == "-c" ]]; then + + echo "Concatenating files and placing in \`css/tmp/\`." + mkdir -p ./css/tmp + cat ./css/dev-common.css > ./css/tmp/footnotes-nottbrpl0.css + cat ./css/dev-{common,layout-reference-container}.css > ./css/tmp/footnotes-nottbrpl1.css + cat ./css/dev-{common,layout-entry-content}.css > ./css/tmp/footnotes-nottbrpl2.css + cat ./css/dev-{common,layout-main-content}.css > ./css/tmp/footnotes-nottbrpl3.css + cat ./css/dev-{common,tooltips}.css > ./css/tmp/footnotes-jqttbrpl0.css + cat ./css/dev-{common,tooltips,layout-reference-container}.css > ./css/tmp/footnotes-jqttbrpl1.css + cat ./css/dev-{common,tooltips,layout-entry-content}.css > ./css/tmp/footnotes-jqttbrpl2.css + cat ./css/dev-{common,tooltips,layout-main-content}.css > ./css/tmp/footnotes-jqttbrpl3.css + cat ./css/dev-{common,tooltips,tooltips-alternative}.css > ./css/tmp/footnotes-alttbrpl0.css + cat ./css/dev-{common,tooltips,tooltips-alternative,layout-reference-container}.css > ./css/tmp/footnotes-alttbrpl1.css + cat ./css/dev-{common,tooltips,tooltips-alternative,layout-entry-content}.css > ./css/tmp/footnotes-alttbrpl2.css + cat ./css/dev-{common,tooltips,tooltips-alternative,layout-main-content}.css > ./css/tmp/footnotes-alttbrpl3.css + cat ./css/settings.css > ./css/tmp/settings.css + echo "Done." + +elif [[ $1 == "-m" ]]; then + + # TODO: this should automatically minifiy all files, outputting into `.min.css` + # files and deleting the original concatenated `.css` files in `css/tmp/`. + # Once that's done, we can change the `rm -r` command in the deploy step to + # `rmdir`, which will throw us an error if we have any minified files that + # haven't been moved over to `dist/css/` for whatever reason. As it currently + # stands, we have no error checking in place. + echo "Minifying files (TODO)..." + mkdir -p ./dist/css + for f in ./css/tmp/*.css; do + filename=$(basename $f .css) + echo $filename + # TODO: automated minification + echo $filename Done + done + echo "Done." + +elif [[ $1 == "-d" ]]; then + + echo "Deploying minified files to \`dist/css/\`..." + rm -r ./dist + mkdir -p ./dist/css + for f in ./css/tmp/*.min.css; do + filename=$(basename $f .css) + echo Moving $filename + mv $f ./dist/css + echo $filename Moved + done + echo "Deleting temporary files..." + rm -r ./css/tmp + echo "Done." + +else + + echo -e "Concatenates, minifies (TODO) and deploys stylesheets for distribution.\n" + echo -e "12 unified style sheets are concatenated out of these files:\n" + echo "\`dev-common.css\`" + echo "\`dev-tooltips.css\`" + echo "\`dev-tooltips-alternative.css\`" + echo "\`dev-layout-reference-container.css\`" + echo "\`dev-layout-entry-content.css\`" + echo -e "\`dev-layout-main-content.css\`\n" + echo "Command: \`-c\`: Concatenate \`dev-*\` CSS files into temporary directory." + echo "Command: \`-m\`: Minify files (TODO)." + echo "Command: \`-d\`: Deploy minified files to \`dist/css/\` and remove temporary files." + echo "No command, \"--help\", or anything else: Output this help section." + +fi diff --git a/_tools/build.sh b/_tools/build.sh new file mode 100755 index 0000000..13a7def --- /dev/null +++ b/_tools/build.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Moves everything except the stylesheets over to `dist/` + +cp -r -t dist class/ js/ img/ languages/ templates/ +cp -t dist features.txt license.txt readme.txt footnotes.php includes.php wpml-config.xml customized-documentation-schema.txt customized-template-stack.txt CONTRIBUTING.md README.md SECURITY.md +# TODO: once automatic minification is implemented, this should handle that. +# For now, we shall have to assume that this command is being run on a repo. with +# minimised stylesheet files already in `dist/css/`. diff --git a/_tools/setup.sh b/_tools/setup.sh old mode 100644 new mode 100755 diff --git a/composer.json b/composer.json index 85ecd48..27eab43 100644 --- a/composer.json +++ b/composer.json @@ -1,11 +1,13 @@ { + "name": "markcheret/footnotes", + "description": "footnotes aims to be the all-in-one solution for displaying an automatically-generated list of references on your WordPress Page or Post.", + "license": "GPL-3.0-or-later", + "scripts": { + "build": "./_tools/build.sh", + "post-install-cmd": "./_tools/setup.sh" + }, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^0.7.1", "wp-coding-standards/wpcs": "^2.3" - }, - "scripts": { - "post-install-cmd": [ - "bash _tools/setup.sh" - ] } } diff --git a/composer.lock b/composer.lock index 9e0ee7c..ceae236 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3a147d50695956de52f7cbf827b47830", + "content-hash": "0d4821c9dd1b0f00e1204cc22488f77f", "packages": [], "packages-dev": [ { diff --git a/development/customized-documentation-schema.txt b/customized-documentation-schema.txt similarity index 100% rename from development/customized-documentation-schema.txt rename to customized-documentation-schema.txt diff --git a/development/customized-template-stack.txt b/customized-template-stack.txt similarity index 100% rename from development/customized-template-stack.txt rename to customized-template-stack.txt diff --git a/development/csscat.sh b/development/csscat.sh deleted file mode 100755 index 1d5c453..0000000 --- a/development/csscat.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash -# 2021-02-15T1839+0100 -# Last modified: 2021-02-16T0155+0100 -# csscat.sh -# Concatenates CSS files; deletes the concatenations after they’ve been minified. -# -# 12 unified style sheets are concatenated out of these files: -# dev-common.css -# dev-tooltips.css -# dev-tooltips-alternative.css -# dev-layout-reference-container.css -# dev-layout-entry-content.css -# dev-layout-main-content.css -# -echo "Running $(dirname "$0")/csscat.sh" -if [[ $1 == "c" ]]; then -echo "Concatenate in csscat/ for minification:" -cd ../css -mkdir csscat -cat dev-common.css > csscat/footnotes-nottbrpl0.css -cat dev-common.css dev-layout-reference-container.css > csscat/footnotes-nottbrpl1.css -cat dev-common.css dev-layout-entry-content.css > csscat/footnotes-nottbrpl2.css -cat dev-common.css dev-layout-main-content.css > csscat/footnotes-nottbrpl3.css -cat dev-common.css dev-tooltips.css > csscat/footnotes-jqttbrpl0.css -cat dev-common.css dev-tooltips.css dev-layout-reference-container.css > csscat/footnotes-jqttbrpl1.css -cat dev-common.css dev-tooltips.css dev-layout-entry-content.css > csscat/footnotes-jqttbrpl2.css -cat dev-common.css dev-tooltips.css dev-layout-main-content.css > csscat/footnotes-jqttbrpl3.css -cat dev-common.css dev-tooltips.css dev-tooltips-alternative.css > csscat/footnotes-alttbrpl0.css -cat dev-common.css dev-tooltips.css dev-tooltips-alternative.css dev-layout-reference-container.css > csscat/footnotes-alttbrpl1.css -cat dev-common.css dev-tooltips.css dev-tooltips-alternative.css dev-layout-entry-content.css > csscat/footnotes-alttbrpl2.css -cat dev-common.css dev-tooltips.css dev-tooltips-alternative.css dev-layout-main-content.css > csscat/footnotes-alttbrpl3.css -echo "Done." -elif [[ $1 == "d" ]]; then -echo "Move minified to css/ and delete concatenations and their temp dir:" -cd ../css/csscat -mv footnotes-nottbrpl0.min.css .. -mv footnotes-nottbrpl1.min.css .. -mv footnotes-nottbrpl2.min.css .. -mv footnotes-nottbrpl3.min.css .. -mv footnotes-jqttbrpl0.min.css .. -mv footnotes-jqttbrpl1.min.css .. -mv footnotes-jqttbrpl2.min.css .. -mv footnotes-jqttbrpl3.min.css .. -mv footnotes-alttbrpl0.min.css .. -mv footnotes-alttbrpl1.min.css .. -mv footnotes-alttbrpl2.min.css .. -mv footnotes-alttbrpl3.min.css .. -cd .. -rm -r csscat -echo "Done." -else -echo "Concatenates CSS files; deletes the concatenations after they’ve been minified." -echo "" -echo "12 unified style sheets are concatenated out of these files:" -echo "" -echo "dev-common.css" -echo "" -echo "dev-tooltips.css" -echo "dev-tooltips-alternative.css" -echo "" -echo "dev-layout-reference-container.css" -echo "dev-layout-entry-content.css" -echo "dev-layout-main-content.css" -echo "" -echo "Command: c: Concatenate temporary files waiting for minification." -echo "Command: d: Move the minified files to css/, delete the temporary." -echo "No command, \"--help\", or anything else: Output this help section." -fi