feat: initial commit

This commit is contained in:
Oliver Davies 2023-10-18 15:19:03 +02:00 committed by Oliver Davies
commit a96d506f04
39 changed files with 18010 additions and 0 deletions

2
.dockerignore Normal file
View file

@ -0,0 +1,2 @@
/README.md
/.github/

12
.env.example Normal file
View file

@ -0,0 +1,12 @@
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
export DOCKER_UID=1000
export COMPOSE_PROJECT_NAME=docker-example-drupal-commerce-kickstart
export COMPOSE_PROFILES=web,php,database
export DOCKER_WEB_VOLUME=.:/app
export MYSQL_DATABASE=app
export MYSQL_PASSWORD=app
export MYSQL_USER=app

7
.githooks/pre-push Executable file
View file

@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
set -euo pipefail
just test-commit

25
.githooks/prepare-commit-msg Executable file
View file

@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
# Load the issue ID from an `.issue-id` file within the project and replace the
# `ISSUE_ID` placeholder within a Git commit message.
#
# For example, running `echo "OD-123" > .issue-id` will add `Refs: OD-123` to
# the commit message.
#
# This also works with multiple issue IDs in the same string, e.g.
# "OD-123 OD-456", or IDs on multiple lines.
set -euo pipefail
PROJECT_DIR=$(git rev-parse --show-toplevel)
ISSUE_FILE="$PROJECT_DIR/.issue-id"
if [ -f "${ISSUE_FILE}" ]; then
ISSUE_IDS=$(cat "${ISSUE_FILE}" | tr '\n' ',' | tr ' ' ',' | sed 's/,$//' | sed 's/,/, /g')
if [ -n "${ISSUE_IDS}" ]; then
sed -i.bak "s/# Refs:/Refs: $ISSUE_IDS/" "$1"
fi
fi

25
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,25 @@
name: CI
on:
pull_request:
push:
workflow_dispatch:
env:
COMPOSE_DOCKER_CLI_BUILD: 1
DOCKER_BUILDKIT: 1
DOCKER_UID: 1001
jobs:
build_and_test:
name: Build and test
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
- name: Build and test
run: |
./run ci:test

40
.gitignore vendored Normal file
View file

@ -0,0 +1,40 @@
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
.editorconfig
.env
.gitattributes
vendor/
web/.csslintrc
web/.eslintignore
web/.eslintrc.json
web/.ht.router.php
web/.htaccess
web/INSTALL.txt
web/README.md
web/autoload.php
web/core/
web/example.gitignore
web/index.php
web/modules/README.txt
web/modules/contrib/
web/profiles/README.txt
web/robots.txt
web/sites/*/files/
web/sites/*/private/
web/sites/*/services*.yml
web/sites/*/settings*.php
web/sites/README.txt
web/sites/default/default.services.yml
web/sites/default/default.settings.php
web/sites/development.services.yml
web/sites/example.settings.local.php
web/sites/example.sites.php
web/sites/simpletest/
web/themes/README.txt
web/themes/contrib/
web/update.php
web/web.config
# Docker.
.env
docker-compose.override.yaml

2
.hadolint.yaml Normal file
View file

@ -0,0 +1,2 @@
ignore:
- DL3059

67
Dockerfile Normal file
View file

@ -0,0 +1,67 @@
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
FROM php:8.1-fpm-bullseye AS base
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
RUN which composer && composer -V
ARG DOCKER_UID=1000
ENV DOCKER_UID="${DOCKER_UID}"
WORKDIR /app
RUN adduser --disabled-password --uid "${DOCKER_UID}" app \
&& chown app:app -R /app
USER app
ENV PATH="${PATH}:/app/bin:/app/vendor/bin"
COPY --chown=app:app composer.* ./
################################################################################
FROM base AS build
USER root
RUN apt-get update -yqq \
&& apt-get install -yqq --no-install-recommends \
git libpng-dev libjpeg-dev libzip-dev mariadb-client unzip \
&& rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \
&& apt-get clean
RUN docker-php-ext-configure gd --with-jpeg
RUN docker-php-ext-install bcmath gd pdo_mysql zip
COPY --chown=app:app phpunit.xml* ./
COPY --chown=app:app config config
COPY --chown=app:app patches patches
COPY --chown=app:app scripts scripts
USER app
RUN composer validate
RUN composer install
COPY --chown=app:app tools/docker/images/php/root /
ENTRYPOINT ["/usr/local/bin/docker-entrypoint-php"]
CMD ["php-fpm"]
################################################################################
FROM nginx:1 as web
EXPOSE 8080
WORKDIR /app
COPY tools/docker/images/web/root /

339
LICENSE Normal file
View file

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{description}
Copyright (C) {year} {fullname}
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
{signature of Ty Coon}, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

1
README.md Normal file
View file

@ -0,0 +1 @@
# docker-example-drupal-commerce-kickstart

51
build.yaml Normal file
View file

@ -0,0 +1,51 @@
name: docker-example-drupal-commerce-kickstart
language: php
type: drupal
web:
type: nginx
database:
type: mariadb
version: 10
php:
version: 8.1-fpm-bullseye
phpcs:
paths:
- web/modules/custom
standards:
- Drupal
- DrupalPractice
phpstan:
level: max
paths:
- web/modules/custom
drupal:
docroot: web
docker-compose:
services:
- database
- php
- web
dockerfile:
stages:
build:
extra_directories:
- config
- patches
- scripts
commands:
- composer validate
- composer install
extensions:
install:
- bcmath
experimental:
createGitHubActionsConfiguration: true
runGitHooksBeforePush: true
useNewDatabaseCredentials: true

169
composer.json Normal file
View file

@ -0,0 +1,169 @@
{
"name": "centarro/commerce-kickstart-project",
"description": "Centarro Commerce Kickstart 3.x project template",
"type": "project",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "Centarro",
"role": "info@centarro.io"
}
],
"repositories": {
"commerce_demo": {
"type": "vcs",
"url": "https://git.drupalcode.org/project/commerce_demo.git"
},
"jquery-ui-touch-punch": {
"type": "package",
"package": {
"name": "furf/jquery-ui-touch-punch",
"version": "0.2.3",
"type": "drupal-library",
"dist": {
"type": "zip",
"url": "https://github.com/furf/jquery-ui-touch-punch/archive/4bc009145202d9c7483ba85f3a236a8f3470354d.zip"
}
}
},
"select2": {
"type": "package",
"package": {
"name": "select2/select2",
"version": "4.1.0-rc.0",
"type": "drupal-library",
"dist": {
"type": "zip",
"url": "https://github.com/select2/select2/archive/refs/tags/4.1.0-rc.0.zip"
}
}
},
"drupal": {
"type": "composer",
"url": "https://packages.drupal.org/8"
}
},
"config": {
"bin-dir": "bin",
"sort-packages": true,
"allow-plugins": {
"composer/installers": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"cweagans/composer-patches": true,
"drupal/core-composer-scaffold": true,
"drupal/core-project-message": true,
"oomphinc/composer-installers-extender": true,
"phpstan/extension-installer": true,
"zaporylie/composer-drupal-optimizations": true
}
},
"require": {
"php": ">=8.1",
"ext-curl": "*",
"centarro/certified-projects": "^1.0",
"centarro/commerce_kickstart": "^3.0",
"composer/installers": "^2.0",
"cweagans/composer-patches": "^1.7",
"drupal/core-composer-scaffold": "^10",
"drupal/core-project-message": "^10",
"drupal/core-recommended": "^10",
"drupal/default_content": "^2",
"drush/drush": "^11.4",
"vlucas/phpdotenv": "^5.1",
"webflo/drupal-finder": "^1.2",
"webmozart/path-util": "^2.3"
},
"require-dev": {
"drupal/core-dev": "^10",
"zaporylie/composer-drupal-optimizations": "^1.2"
},
"conflict": {
"drupal/drupal": "*"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"classmap": [
"scripts/composer/ScriptHandler.php"
],
"files": ["load.environment.php"]
},
"scripts": {
"drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold",
"pre-install-cmd": [
"DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
],
"pre-update-cmd": [
"DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
],
"post-install-cmd": [
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
],
"post-update-cmd": [
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
]
},
"extra": {
"composer-exit-on-patch-failure": true,
"patches": {
"drupal/default_content": {
"#3160146 Add a Normalizer and Denormalizer to support Layout Builder": "patches/default_content/3160146-layout-builder.patch"
}
},
"patchLevel": {
"drupal/core": "-p2",
"drupal/default_content": "-p1"
},
"drupal-scaffold": {
"locations": {
"web-root": "web/"
},
"overwrite": true,
"file-mapping": {
"[web-root]/libraries/jquery-ui-touch-punch/jquery.ui.touch-punch.min.js": "libraries/jquery-ui-touch-punch/jquery.ui.touch-punch.min.js",
"[web-root]/libraries/select2/dist/js/select2.min.js": "libraries/select2/dist/js/select2.min.js",
"[web-root]/libraries/select2/dist/css/select2.min.css": "libraries/select2/dist/css/select2.min.css"
}
},
"installer-paths": {
"web/core": ["type:drupal-core"],
"libraries/{$name}": [
"furf/jquery-ui-touch-punch",
"select2/select2"
],
"web/libraries/{$name}": [
"type:drupal-library"
],
"web/modules/contrib/{$name}": [
"type:drupal-module"
],
"web/profiles/contrib/{$name}": [
"type:drupal-profile"
],
"web/themes/contrib/{$name}": [
"type:drupal-theme"
],
"drush/Commands/contrib/{$name}": [
"type:drupal-drush"
]
},
"drupal-core-project-message": {
"include-keys": ["homepage", "support"],
"post-create-project-cmd-message": [
"<bg=magenta;fg=white> </>",
"<bg=magenta;fg=white> Congratulations, you installed Commerce Kickstart! </>",
"<bg=magenta;fg=white> </>",
"",
"<bg=yellow;fg=black>Next steps</>:",
" * Install the site: https://www.drupal.org/docs/installing-drupal",
" * Read the Drupal Commerce docs: https://docs.drupalcommerce.org/commerce2",
" * Get support: https://drupal.stackexchange.com/",
" * Get involved with the Drupal community:",
" https://www.drupal.org/getting-involved",
" * Remove the plugin that prints this message:",
" composer remove drupal/core-project-message"
]
}
}
}

16381
composer.lock generated Normal file

File diff suppressed because it is too large Load diff

View file

View file

@ -0,0 +1,24 @@
# Deny all requests from Apache 2.4+.
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
# Deny all requests from Apache 2.0-2.2.
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>
# Turn off all options we don't need.
Options -Indexes -ExecCGI -Includes -MultiViews
# Set the catch-all handler to prevent scripts from being executed.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
<Files *>
# Override the handler again if we're run later in the evaluation list.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
</Files>
# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php7.c>
php_flag engine off
</IfModule>

View file

@ -0,0 +1 @@
default_transport: ddev_smtp

0
config/sync/.gitkeep Normal file
View file

77
docker-compose.yaml Normal file
View file

@ -0,0 +1,77 @@
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
x-proxy: &default-proxy
networks:
- default
- web
labels:
- "traefik.docker.network=traefik_proxy"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host(
`${COMPOSE_PROJECT_NAME}.localhost`,
)"
x-app: &default-app
volumes:
- "${DOCKER_WEB_VOLUME:-./web:/app/web}"
env_file:
- .env
restart: "${DOCKER_RESTART_POLICY:-unless-stopped}"
networks:
- default
deploy:
resources:
limits:
cpus: "${DOCKER_MYSQL_CPUS:-0}"
memory: "${DOCKER_MYSQL_MEMORY:-0}"
labels:
- "traefik.enabled=false"
tty: true
services:
web:
<<: [*default-proxy, *default-app]
build:
context: .
target: web
depends_on:
- php
profiles: [web]
php:
<<: [*default-app]
build:
context: .
target: build
args:
- "DOCKER_UID=${DOCKER_UID:-1000}"
volumes:
- .:/app
depends_on:
- database
profiles: [php]
database:
image: mariadb:10
deploy:
resources:
limits:
cpus: "${DOCKER_MYSQL_CPUS:-0}"
memory: "${DOCKER_MYSQL_MEMORY:-0}"
volumes:
- db-data:/var/lib/mysql
env_file:
- .env
labels:
- "traefik.enabled=false"
environment:
MYSQL_RANDOM_ROOT_PASSWORD: true
profiles: [database]
volumes:
db-data: {}
networks:
web:
external: true
name: traefik_proxy

View file

@ -0,0 +1,38 @@
<?php
namespace Drush\Commands;
use Consolidation\AnnotatedCommand\CommandData;
/**
* Edit this file to reflect your organization's needs.
*/
class PolicyCommands extends DrushCommands {
/**
* Prevent catastrophic braino. Note that this file has to be local to the
* machine that initiates the sql:sync command.
*
* @hook validate sql:sync
*
* @throws \Exception
*/
public function sqlSyncValidate(CommandData $commandData) {
if ($commandData->input()->getArgument('target') == '@prod') {
throw new \Exception(dt('Per !file, you may never overwrite the production database.', ['!file' => __FILE__]));
}
}
/**
* Limit rsync operations to production site.
*
* @hook validate core:rsync
*
* @throws \Exception
*/
public function rsyncValidate(CommandData $commandData) {
if (preg_match("/^@prod/", $commandData->input()->getArgument('target'))) {
throw new \Exception(dt('Per !file, you may never rsync to the production site.', ['!file' => __FILE__]));
}
}
}

1
drush/README.md Normal file
View file

@ -0,0 +1 @@
This directory contains commands, configuration and site aliases for Drush. See https://packagist.org/search/?type=drupal-drush for a directory of Drush commands installable via Composer.

6
drush/drush.yml Normal file
View file

@ -0,0 +1,6 @@
#
# A Drush configuration file
#
# Docs at https://github.com/drush-ops/drush/blob/master/examples/example.drush.yml
#
# Edit or remove this file as needed.

14
drush/sites/self.site.yml Normal file
View file

@ -0,0 +1,14 @@
# Edit or remove this file as needed.
# Docs at https://github.com/drush-ops/drush/blob/master/examples/example.site.yml
#prod:
# host: prod.domain.com
# user: www-admin
# root: /path/to/drupal
# uri: http://www.example.com
#
#stage:
# host: stage.domain.com
# user: www-admin
# root: /path/to/drupal
# uri: http://stage.example.com

18
load.environment.php Normal file
View file

@ -0,0 +1,18 @@
<?php
/**
* This file is included very early. See autoload.files in composer.json and
* https://getcomposer.org/doc/04-schema.md#files
*/
use Dotenv\Dotenv;
/**
* Load any .env file. See /.env.example.
*
* Drupal has no official method for loading environment variables and uses
* getenv() in some places.
*/
$dotenv = Dotenv::createUnsafeImmutable(__DIR__);
$dotenv->safeLoad();

View file

@ -0,0 +1,129 @@
From 09cf17028ae510e99e0430ce735536bc37d0d3ea Mon Sep 17 00:00:00 2001
From: Emil Johnsson <emil@kodamera.se>
Date: Tue, 1 Feb 2022 13:09:02 +0100
Subject: [PATCH 1/2] Applied patch from #37 by heddn
---
src/Normalizer/ContentEntityNormalizer.php | 38 ++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/src/Normalizer/ContentEntityNormalizer.php b/src/Normalizer/ContentEntityNormalizer.php
index 08d68ee..3ece0fa 100644
--- a/src/Normalizer/ContentEntityNormalizer.php
+++ b/src/Normalizer/ContentEntityNormalizer.php
@@ -22,6 +22,8 @@ use Drupal\pathauto\PathautoState;
use Drupal\serialization\Normalizer\SerializedColumnNormalizerTrait;
use Drupal\user\UserInterface;
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
+use Drupal\layout_builder\Section;
+use Drupal\layout_builder\Plugin\DataType\SectionData;
/**
* Normalizes and denormalizes content entities.
@@ -253,6 +255,22 @@ class ContentEntityNormalizer implements ContentEntityNormalizerInterface {
}
$property->setValue($target_entity);
}
+ elseif ($property instanceof SectionData) {
+ // Rebuild references on layout_builder.
+ foreach ($value['components'] as $key => $component) {
+ if (isset($component['configuration']['id'])) {
+ [$component_type] = explode(PluginBase::DERIVATIVE_SEPARATOR, $component['configuration']['id']);
+ if ($component_type == 'inline_block') {
+ $target_uuid = $component['additional']['target_uuid'] ?? NULL;
+ if ($target_uuid && $block_content = $this->entityRepository->loadEntityByUuid('block_content', $target_uuid)) {
+ $value['components'][$key]['configuration']['block_revision_id'] = $block_content->getRevisionId();
+ }
+ }
+ }
+ }
+ $section_value = Section::fromArray($value);
+ $property->setValue($section_value);
+ }
else {
$property->setValue($value);
}
@@ -419,6 +437,26 @@ class ContentEntityNormalizer implements ContentEntityNormalizerInterface {
$value = $target->uuid();
}
}
+ elseif ($property instanceof SectionData && $property->getValue() instanceof Section) {
+ $value = $property->getValue()->toArray();
+
+ // Layout Sections reference inline blocks by id, we need to reference by
+ // UUID and make sure the section has a dependency on the inline_block.
+ foreach ($value['components'] as $key => $component) {
+ if (isset($component['configuration']['id'])) {
+ // This is only valid for inline_block.
+ [$component_type, $component_bundle] = explode(PluginBase::DERIVATIVE_SEPARATOR, $component['configuration']['id']);
+ if ($component_type == 'inline_block') {
+ $block_revision_id = $component['configuration']['block_revision_id'];
+ $block_content = $this->entityTypeManager->getStorage('block_content')->loadRevision($block_revision_id);
+ if ($block_content) {
+ $value['components'][$key]['additional']['target_uuid'] = $block_content->uuid();
+ $this->addDependency($block_content);
+ }
+ }
+ }
+ }
+ }
elseif ($property instanceof Uri) {
$value = $property->getValue();
$scheme = parse_url($value, PHP_URL_SCHEME);
--
GitLab
From 3cd0c7f52f9dff759518fa5d940cb000abfdd37f Mon Sep 17 00:00:00 2001
From: Emil Johnsson <emil@kodamera.se>
Date: Tue, 1 Feb 2022 13:09:10 +0100
Subject: [PATCH 2/2] Applied patch from #41 by S3b0uN3t (with code cleanup)
---
src/Exporter.php | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/src/Exporter.php b/src/Exporter.php
index e0df909..3443118 100644
--- a/src/Exporter.php
+++ b/src/Exporter.php
@@ -11,6 +11,7 @@ use Drupal\Core\Serialization\Yaml;
use Drupal\default_content\Event\DefaultContentEvents;
use Drupal\default_content\Event\ExportEvent;
use Drupal\default_content\Normalizer\ContentEntityNormalizerInterface;
+use Drupal\layout_builder\Plugin\Block\InlineBlock;
use Drupal\user\UserInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -199,6 +200,28 @@ class Exporter implements ExporterInterface {
protected function getEntityReferencesRecursive(ContentEntityInterface $entity, $depth = 0, array &$indexed_dependencies = []) {
$entity_dependencies = $entity->referencedEntities();
+ // Get dependencies from layout builder.
+ if ($entity->hasField('layout_builder__layout')) {
+ $section_data = $entity->get('layout_builder__layout');
+ foreach ($section_data->getSections() as $section) {
+ $components = $section->getComponents();
+ foreach ($components as $component) {
+ $plugin = $component->getPlugin();
+ if ($plugin instanceof InlineBlock) {
+ $configuration = $component->get('configuration');
+ if (!empty($block_revision_id = $configuration['block_revision_id'])) {
+ $block_content = $this->entityTypeManager
+ ->getStorage('block_content')
+ ->loadRevision($block_revision_id);
+ if ($block_content) {
+ $entity_dependencies[] = $block_content;
+ }
+ }
+ }
+ }
+ }
+ }
+
foreach ($entity_dependencies as $dependent_entity) {
// Config entities should not be exported but rather provided by default
// config.
--
GitLab

32
phpcs.xml.dist Normal file
View file

@ -0,0 +1,32 @@
<?xml version="1.0"?>
<!-- Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. -->
<ruleset name="docker-example-drupal-commerce-kickstart coding standards">
<description>PHPCS configuration file for docker-example-drupal-commerce-kickstart.</description>
<file>web/modules/custom</file>
<arg value="np"/>
<rule ref="DrupalPractice"/>
<rule ref="Drupal">
<exclude name="Drupal.Commenting.ClassComment.Missing"/>
<exclude name="Drupal.Commenting.DataTypeNamespace.DataTypeNamespace"/>
<exclude name="Drupal.Commenting.Deprecated"/>
<exclude name="Drupal.Commenting.DocComment.ContentAfterOpen"/>
<exclude name="Drupal.Commenting.DocComment.MissingShort"/>
<exclude name="Drupal.Commenting.FunctionComment.IncorrectParamVarName"/>
<exclude name="Drupal.Commenting.FunctionComment.IncorrectTypeHint"/>
<exclude name="Drupal.Commenting.FunctionComment.InvalidReturn"/>
<exclude name="Drupal.Commenting.FunctionComment.Missing"/>
<exclude name="Drupal.Commenting.FunctionComment.MissingParamComment"/>
<exclude name="Drupal.Commenting.FunctionComment.MissingReturnComment"/>
<exclude name="Drupal.Commenting.FunctionComment.ParamTypeSpaces"/>
<exclude name="Drupal.Commenting.FunctionComment.TypeHintMissing"/>
<exclude name="Drupal.Commenting.InlineComment.DocBlock"/>
<exclude name="Drupal.Commenting.VariableComment.Missing"/>
<exclude name="Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps"/>
<exclude name="DrupalPractice.Objects.StrictSchemaDisabled.StrictConfigSchema"/>
</rule>
</ruleset>

9
phpstan.neon.dist Normal file
View file

@ -0,0 +1,9 @@
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
parameters:
level: max
excludePaths:
- *Test.php
- *TestBase.php
paths:
- web/modules/custom

37
phpunit.xml.dist Normal file
View file

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. -->
<phpunit
beStrictAboutChangesToGlobalState="true"
beStrictAboutOutputDuringTests="false"
beStrictAboutTestsThatDoNotTestAnything="true"
bootstrap="web/core/tests/bootstrap.php"
cacheResult="false"
colors="true"
failOnWarning="true"
printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter"
>
<php>
<env name="BROWSERTEST_OUTPUT_BASE_URL" value=""/>
<env name="BROWSERTEST_OUTPUT_DIRECTORY" value=""/>
<env name="MINK_DRIVER_ARGS" value=''/>
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value=''/>
<env name="MINK_DRIVER_CLASS" value=''/>
<env name="SIMPLETEST_BASE_URL" value="http://web"/>
<env name="SIMPLETEST_DB" value="sqlite://localhost//dev/shm/test.sqlite"/>
<ini name="error_reporting" value="32767"/>
<ini name="memory_limit" value="-1"/>
</php>
<testsuites>
<testsuite name="functional">
<directory>./web/modules/custom/**/tests/**/Functional</directory>
</testsuite>
<testsuite name="kernel">
<directory>./web/modules/custom/**/tests/**/Kernel</directory>
</testsuite>
<testsuite name="unit">
<directory>./web/modules/custom/**/tests/**/Unit</directory>
</testsuite>
</testsuites>
</phpunit>

118
run Executable file
View file

@ -0,0 +1,118 @@
#!/usr/bin/env bash
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
set -eu
# Run automated tests as part of the Continuous Integration (CI) pipeline.
function ci:test {
lint:dockerfile
docker compose version
docker network create traefik_proxy
cp --no-clobber .env.example .env
docker compose build --progress plain
docker compose up --detach
docker compose logs
composer install --quiet --no-progress
test --testdox
quality
}
# Run a command within the php container.
function cmd {
docker compose exec php "${@}"
}
function coding-standards {
cmd phpcs "${@}"
}
function composer {
_exec php composer "${@}"
}
function drush {
_exec php drush "${@}"
}
function git-hooks:off {
git config --unset core.hooksPath
}
function git-hooks:on {
git config core.hooksPath .githooks
}
# Display a list of all available commands.
function help {
printf "%s <task> [args]\n\nTasks:\n" "${0}"
compgen -A function | grep -v "^_" | cat -n
printf "\nExtended help:\n Each task has comments for general usage\n"
}
function lint:dockerfile {
docker container run --rm -i \
hadolint/hadolint hadolint --ignore DL3008 --ignore DL3059 -t style "${@}" - < Dockerfile
}
function quality {
coding-standards
static-analysis
}
function start {
cp -v --no-clobber .env.example .env
docker compose up -d
}
function static-analysis {
cmd phpstan --memory-limit=-1 --no-progress "${@}"
}
function stop {
docker compose down
}
function test {
_exec php phpunit --colors=always "${@}"
}
function test:commit {
test --testdox --testsuite functional
test --testdox --testsuite kernel
test --testdox --testsuite unit
quality
}
function _exec {
docker compose exec -T "${@}"
}
function _run {
local service="${1}"
local command="${2}"
docker compose run \
--entrypoint "${command}" \
--no-deps \
--rm \
-T \
"${service}" "${@}"
}
TIMEFORMAT=$'\nTask completed in %3lR'
time "${@:-help}"
# vim: ft=bash

View file

@ -0,0 +1,97 @@
<?php
/**
* @file
* Contains \DrupalProject\composer\ScriptHandler.
*/
namespace DrupalProject\composer;
use Composer\Script\Event;
use Composer\Semver\Comparator;
use Drupal\Core\Site\Settings;
use DrupalFinder\DrupalFinder;
use Symfony\Component\Filesystem\Filesystem;
use Webmozart\PathUtil\Path;
class ScriptHandler {
public static function createRequiredFiles(Event $event) {
$fs = new Filesystem();
$drupalFinder = new DrupalFinder();
$drupalFinder->locateRoot(getcwd());
$drupalRoot = $drupalFinder->getDrupalRoot();
$composerRoot = $drupalFinder->getComposerRoot();
$dirs = [
'modules',
'profiles',
'themes',
];
// Required for unit testing
foreach ($dirs as $dir) {
if (!$fs->exists($drupalRoot . '/'. $dir)) {
$fs->mkdir($drupalRoot . '/'. $dir);
$fs->touch($drupalRoot . '/'. $dir . '/.gitkeep');
}
}
// Prepare the settings file for installation
if (!$fs->exists($drupalRoot . '/sites/default/settings.php') && $fs->exists($drupalRoot . '/profiles/contrib/commerce_kickstart/assets/settings.php')) {
$fs->copy($drupalRoot . '/profiles/contrib/commerce_kickstart/assets/settings.php', $drupalRoot . '/sites/default/settings.php');
$fs->chmod($drupalRoot . '/sites/default/settings.php', 0666);
$event->getIO()->write("Created a sites/default/settings.php file with chmod 0666");
}
// Create the files directory with chmod 0777
if (!$fs->exists($drupalRoot . '/sites/default/files')) {
$oldmask = umask(0);
$fs->mkdir($drupalRoot . '/sites/default/files', 0777);
umask($oldmask);
$event->getIO()->write("Created a sites/default/files directory with chmod 0777");
}
// Mirror config splits from the profile to the project config directory.
$fs->mirror($drupalRoot . '/profiles/contrib/commerce_kickstart/config/splits', $composerRoot . '/config/splits');
$event->getIO()->write("Mirrored config splits from Commerce Kickstart into ../config/splits");
}
/**
* Checks if the installed version of Composer is compatible.
*
* Composer 1.0.0 and higher consider a `composer install` without having a
* lock file present as equal to `composer update`. We do not ship with a lock
* file to avoid merge conflicts downstream, meaning that if a project is
* installed with an older version of Composer the scaffolding of Drupal will
* not be triggered. We check this here instead of in drupal-scaffold to be
* able to give immediate feedback to the end user, rather than failing the
* installation after going through the lengthy process of compiling and
* downloading the Composer dependencies.
*
* @see https://github.com/composer/composer/pull/5035
*/
public static function checkComposerVersion(Event $event) {
$composer = $event->getComposer();
$io = $event->getIO();
$version = $composer::VERSION;
// The dev-channel of composer uses the git revision as version number,
// try to the branch alias instead.
if (preg_match('/^[0-9a-f]{40}$/i', $version)) {
$version = $composer::BRANCH_ALIAS_VERSION;
}
// If Composer is installed through git we have no easy way to determine if
// it is new enough, just display a warning.
if ($version === '@package_version@' || $version === '@package_branch_alias_version@') {
$io->writeError('<warning>You are running a development version of Composer. If you experience problems, please update Composer to the latest stable version.</warning>');
}
elseif (Comparator::lessThan($version, '1.0.0')) {
$io->writeError('<error>Drupal-project requires Composer version 1.0.0 or higher. Please update your Composer before continuing</error>.');
exit(1);
}
}
}

View file

@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
[[ -f composer.json && ! -d vendor ]] && composer install
eval "$@"

View file

@ -0,0 +1,4 @@
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
max_vars_input = 1000
memory_limit = 128M

View file

@ -0,0 +1,22 @@
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
server {
server_name _;
root /app/web;
location / {
try_files $uri /index.php?$query_string;
}
location ~ \.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
try_files $fastcgi_script_name =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param QUERY_STRING $query_string;
fastcgi_intercept_errors on;
fastcgi_pass php:9000;
}
}

View file

@ -0,0 +1,41 @@
# jQuery UI Touch Punch
## Touch Event Support for jQuery UI
> **jQuery UI Touch Punch is a small hack that enables the use of touch events on sites using the jQuery UI user interface library.**
_[Visit the official Touch Punch website](http://touchpunch.furf.com)._
Currently, [jQuery UI](http://jqueryui.com/) user interface library does not support the use of touch events in their widgets and interactions. This means that the slick UI you designed and tested in your desktop browser will fail on most, if not all, touch-enabled mobile devices, because jQuery UI listens to mouse events—mouseover, mousemove and mouseout—not touch events—touchstart, touchmove and touchend.
That's where jQuery UI Touch Punch comes in. Touch Punch works by using [simulated events](https://developer.mozilla.org/en/DOM/document.createEvent) to map [touch events](http://www.html5rocks.com/en/mobile/touch/) to their mouse event analogs. Simply include the script on your page and your touch events will be turned into their corresponding mouse events to which jQuery UI will respond as expected.
As I said, Touch Punch is a hack. It [duck punches](http://en.wikipedia.org/wiki/Monkey_patch) some of jQuery UI's core functionality to handle the mapping of touch events. Touch Punch works with all basic implementations of jQuery UI's interactions and widgets. However, you may find more complex cases where Touch Punch fails. If so, scroll down to learn how you can file and/or fix issues.
This code is dual licensed under the MIT or GPL Version 2 licenses and is therefore free to use, modify and/or distribute, but if you include Touch Punch in other software packages or plugins, please include an attribution to the original software and a link to [this Touch Punch website](http://touchpunch.furf.com/).
## Using Touch Punch is as easy as 1, 2…
Just follow these simple steps to enable touch events in your jQuery UI app:
1. Include jQuery and jQuery UI on your page.
```html
<script src="http://code.jquery.com/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.8.17/jquery-ui.min.js"></script>
```
2. Include Touch Punch after jQuery UI and before its first use.
Please note that if you are using jQuery UI's components, Touch Punch must be included after jquery.ui.mouse.js, as Touch Punch modifies its behavior.
```html
<script src="jquery.ui.touch-punch.min.js"></script>
```
3. There is no 3. Just use jQuery UI as expected and watch it work at the touch of a finger.
```html
<script>$('#widget').draggable();</script>
```
_Tested on iPad, iPhone, Android and other touch-enabled mobile devices._

View file

@ -0,0 +1,10 @@
{
"name": "jqueryui-touch-punch",
"version": "0.2.3",
"main": "jquery.ui.touch-punch.min.js",
"ignore": [],
"dependencies": {
"jquery": ">=1.6",
"jquery-ui": ">=1.8"
}
}

View file

@ -0,0 +1,10 @@
{
"name": "politsin/jquery-ui-touch-punch",
"version": "1.0",
"description": "Extension to jQuery UI for mobile touch event support.",
"type": "drupal-library",
"keywords": [ "mobile", "touch", "gestures" ],
"authors": [{"name": "Dave Furfero","email": "furf@furf.com"}],
"license": "MIT",
"homepage": "http://touchpunch.furf.com/"
}

View file

@ -0,0 +1,180 @@
/*!
* jQuery UI Touch Punch 0.2.3
*
* Copyright 20112014, Dave Furfero
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* Depends:
* jquery.ui.widget.js
* jquery.ui.mouse.js
*/
(function ($) {
// Detect touch support
$.support.touch = 'ontouchend' in document;
// Ignore browsers without touch support
if (!$.support.touch) {
return;
}
var mouseProto = $.ui.mouse.prototype,
_mouseInit = mouseProto._mouseInit,
_mouseDestroy = mouseProto._mouseDestroy,
touchHandled;
/**
* Simulate a mouse event based on a corresponding touch event
* @param {Object} event A touch event
* @param {String} simulatedType The corresponding mouse event
*/
function simulateMouseEvent (event, simulatedType) {
// Ignore multi-touch events
if (event.originalEvent.touches.length > 1) {
return;
}
event.preventDefault();
var touch = event.originalEvent.changedTouches[0],
simulatedEvent = document.createEvent('MouseEvents');
// Initialize the simulated mouse event using the touch event's coordinates
simulatedEvent.initMouseEvent(
simulatedType, // type
true, // bubbles
true, // cancelable
window, // view
1, // detail
touch.screenX, // screenX
touch.screenY, // screenY
touch.clientX, // clientX
touch.clientY, // clientY
false, // ctrlKey
false, // altKey
false, // shiftKey
false, // metaKey
0, // button
null // relatedTarget
);
// Dispatch the simulated event to the target element
event.target.dispatchEvent(simulatedEvent);
}
/**
* Handle the jQuery UI widget's touchstart events
* @param {Object} event The widget element's touchstart event
*/
mouseProto._touchStart = function (event) {
var self = this;
// Ignore the event if another widget is already being handled
if (touchHandled || !self._mouseCapture(event.originalEvent.changedTouches[0])) {
return;
}
// Set the flag to prevent other widgets from inheriting the touch event
touchHandled = true;
// Track movement to determine if interaction was a click
self._touchMoved = false;
// Simulate the mouseover event
simulateMouseEvent(event, 'mouseover');
// Simulate the mousemove event
simulateMouseEvent(event, 'mousemove');
// Simulate the mousedown event
simulateMouseEvent(event, 'mousedown');
};
/**
* Handle the jQuery UI widget's touchmove events
* @param {Object} event The document's touchmove event
*/
mouseProto._touchMove = function (event) {
// Ignore event if not handled
if (!touchHandled) {
return;
}
// Interaction was not a click
this._touchMoved = true;
// Simulate the mousemove event
simulateMouseEvent(event, 'mousemove');
};
/**
* Handle the jQuery UI widget's touchend events
* @param {Object} event The document's touchend event
*/
mouseProto._touchEnd = function (event) {
// Ignore event if not handled
if (!touchHandled) {
return;
}
// Simulate the mouseup event
simulateMouseEvent(event, 'mouseup');
// Simulate the mouseout event
simulateMouseEvent(event, 'mouseout');
// If the touch interaction did not move, it should trigger a click
if (!this._touchMoved) {
// Simulate the click event
simulateMouseEvent(event, 'click');
}
// Unset the flag to allow other widgets to inherit the touch event
touchHandled = false;
};
/**
* A duck punch of the $.ui.mouse _mouseInit method to support touch events.
* This method extends the widget with bound touch event handlers that
* translate touch events to mouse events and pass them to the widget's
* original mouse event handling methods.
*/
mouseProto._mouseInit = function () {
var self = this;
// Delegate the touch handlers to the widget's element
self.element.bind({
touchstart: $.proxy(self, '_touchStart'),
touchmove: $.proxy(self, '_touchMove'),
touchend: $.proxy(self, '_touchEnd')
});
// Call the original $.ui.mouse init method
_mouseInit.call(self);
};
/**
* Remove the touch event handlers
*/
mouseProto._mouseDestroy = function () {
var self = this;
// Delegate the touch handlers to the widget's element
self.element.unbind({
touchstart: $.proxy(self, '_touchStart'),
touchmove: $.proxy(self, '_touchMove'),
touchend: $.proxy(self, '_touchEnd')
});
// Call the original $.ui.mouse destroy method
_mouseDestroy.call(self);
};
})(jQuery);

View file

@ -0,0 +1,11 @@
/*!
* jQuery UI Touch Punch 0.2.3
*
* Copyright 20112014, Dave Furfero
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* Depends:
* jquery.ui.widget.js
* jquery.ui.mouse.js
*/
!function(a){function f(a,b){if(!(a.originalEvent.touches.length>1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long