-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* UPDATE initial CMS 5 upgrade * UPDATE rework violator to bootstrap alert * UPDATE link field version * UPDATE allow setting a 1 year cookie for violators if they’re closed UPDATE allow specifying/changing the cookie name for flexibility * UPDATE php matrix * UPDATE require-dev * UPDATE cli.yml * UPDATE require-dev elemental * UPDATE move extension fields to models * UPDATE popup model update to support Show Once and cookie name UPDATE popup template * UPDATE logic for single popup based on all available UPDATE phpcs.xml.dist * UPDATE PHPCS adjustments UPDATE remove unused files
- Loading branch information
Showing
19 changed files
with
439 additions
and
330 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 |
---|---|---|
@@ -1,73 +1,11 @@ | ||
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ '**' ] | ||
pull_request: | ||
branches: [ '**' ] | ||
|
||
name: "CI" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
tests: | ||
name: "Tests" | ||
|
||
runs-on: "ubuntu-latest" | ||
|
||
env: | ||
php_extensions: ctype, dom, fileinfo, hash, intl, mbstring, session, simplexml, tokenizer, xml, pdo, mysqli, gd, zip | ||
|
||
services: | ||
mysql: | ||
image: "mysql:5.7" | ||
env: | ||
MYSQL_ALLOW_EMPTY_PASSWORD: true | ||
MYSQL_ROOT_PASSWORD: | ||
MYSQL_DATABASE: test_db | ||
ports: | ||
- 3306/tcp | ||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php-version: | ||
- "7.4" | ||
|
||
steps: | ||
- name: "Checkout" | ||
uses: "actions/checkout@v2" | ||
|
||
- name: "Install PHP with extensions" | ||
uses: "shivammathur/setup-php@v2" | ||
with: | ||
php-version: "${{ matrix.php-version }}" | ||
extensions: "${{ env.php_extensions }}" | ||
coverage: "xdebug" | ||
|
||
- name: "Start mysql service" | ||
run: "sudo /etc/init.d/mysql start" | ||
|
||
- name: "Cache dependencies installed with composer" | ||
uses: "actions/cache@v1" | ||
with: | ||
path: "~/.composer/cache" | ||
key: "php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}" | ||
restore-keys: "php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-" | ||
|
||
- name: "Install dependencies with composer" | ||
run: "composer install --no-ansi --no-interaction --no-progress" | ||
|
||
- name: "Run tests with phpunit/phpunit" | ||
env: | ||
SS_DATABASE_PORT: ${{ job.services.mysql.ports['3306'] }} | ||
run: "vendor/bin/phpunit --coverage-html=build/logs/coverage/html --coverage-xml=build/logs/coverage" | ||
|
||
- name: "Upload code coverage results to CodeCov" | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
files: ./coverage.xml # optional | ||
flags: unittests # optional | ||
|
||
- name: "Run tests with squizlabs/php_codesniffer" | ||
run: "vendor/bin/phpcs -s --report=summary --standard=phpcs.xml.dist --extensions=php,inc --ignore=autoload.php --ignore=vendor/ src/ tests/" | ||
ci: | ||
name: CI | ||
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,17 +1,47 @@ | ||
;(function ($) { | ||
$(window).on("load", function(){ | ||
$.ajax({ | ||
type: 'GET', | ||
url: '/violatordata', | ||
data: { | ||
'isAjax': 1 | ||
} | ||
}) | ||
.done(function (response) { | ||
$('.violators').html(response) | ||
}) | ||
.fail(function (xhr) { | ||
console.log('Error: ' + xhr.responseText); | ||
window.addEventListener('load', function() { | ||
var xhr = new XMLHttpRequest(); | ||
xhr.open('GET', '/violatordata?isAjax=1', true); | ||
|
||
xhr.onload = function() { | ||
if (xhr.status >= 200 && xhr.status < 400) { | ||
document.querySelector('.violators').innerHTML = xhr.responseText; | ||
var violators = document.querySelectorAll('.violators__violator[data-cookiename]'); | ||
violators.forEach(function(violator) { | ||
var cookieName = violator.getAttribute('data-cookiename'); | ||
if (getCookie(cookieName)) { | ||
violator.style.display = 'none'; | ||
} else { | ||
violator.querySelector('.btn-close').addEventListener('click', function() { | ||
setCookie(cookieName, 'true', 365); | ||
}); | ||
} | ||
}); | ||
}); | ||
})(jQuery) | ||
} else { | ||
console.error('Error: ' + xhr.responseText); | ||
} | ||
}; | ||
|
||
xhr.onerror = function() { | ||
console.error('Request failed'); | ||
}; | ||
|
||
xhr.send(); | ||
|
||
function setCookie(name, value, days) { | ||
var date = new Date(); | ||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); | ||
var expires = "expires=" + date.toUTCString(); | ||
document.cookie = name + "=" + value + ";" + expires + ";path=/"; | ||
} | ||
|
||
function getCookie(name) { | ||
var nameEQ = name + "="; | ||
var ca = document.cookie.split(';'); | ||
for (var i = 0; i < ca.length; i++) { | ||
var c = ca[i]; | ||
while (c.charAt(0) == ' ') c = c.substring(1, c.length); | ||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); | ||
} | ||
return null; | ||
} | ||
}); |
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,50 @@ | ||
document.addEventListener('DOMContentLoaded', function() { | ||
// Function to set a cookie | ||
function setCookie(name, value, days) { | ||
var expires = ""; | ||
if (days) { | ||
var date = new Date(); | ||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); | ||
expires = "; expires=" + date.toUTCString(); | ||
} | ||
document.cookie = name + "=" + (value || "") + expires + "; path=/"; | ||
} | ||
|
||
// Function to get a cookie | ||
function getCookie(name) { | ||
var nameEQ = name + "="; | ||
var ca = document.cookie.split(';'); | ||
for (var i = 0; i < ca.length; i++) { | ||
var c = ca[i]; | ||
while (c.charAt(0) == ' ') c = c.substring(1, c.length); | ||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); | ||
} | ||
return null; | ||
} | ||
|
||
// Function to initialize modals | ||
function initializeModals() { | ||
document.querySelectorAll('.popup__modal').forEach(function(modal) { | ||
var cookieName = modal.getAttribute('data-cookiename'); | ||
|
||
if (!cookieName || !getCookie(cookieName)) { | ||
var bootstrapModal = new bootstrap.Modal(modal); | ||
bootstrapModal.show(); | ||
|
||
modal.querySelector('.btn-close').addEventListener('click', function() { | ||
if (cookieName) { | ||
setCookie(cookieName, 'true', 365); // Set cookie for 1 year | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
// Check if Bootstrap is loaded and initialize modals | ||
var bootstrapCheckInterval = setInterval(function() { | ||
if (typeof bootstrap !== 'undefined') { | ||
clearInterval(bootstrapCheckInterval); | ||
initializeModals(); | ||
} | ||
}, 100); | ||
}); |
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
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 |
---|---|---|
@@ -1,24 +1,13 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="SS4"> | ||
<description>Coding standard for SilverStripe 4.x</description> | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ruleset name="Silverstripe"> | ||
<description>CodeSniffer ruleset for Silverstripe coding conventions.</description> | ||
|
||
<!-- Don't sniff third party libraries --> | ||
<exclude-pattern>*/vendor/*</exclude-pattern> | ||
<exclude-pattern>*/thirdparty/*</exclude-pattern> | ||
<file>src</file> | ||
<file>tests</file> | ||
|
||
<!-- Show progress and output sniff names on violation, and add colours --> | ||
<arg value="sp"/> | ||
<arg name="colors"/> | ||
|
||
<!-- Use PSR-2 as a base standard --> | ||
<rule ref="PSR2"> | ||
<!-- Allow classes to not declare a namespace --> | ||
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/> | ||
|
||
<!-- Allow underscores in class names --> | ||
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/> | ||
|
||
<!-- Allow non camel cased method names --> | ||
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/> | ||
<!-- base rules are PSR-12 --> | ||
<rule ref="PSR12" > | ||
<!-- You may need to use this exclusion if you override some core methods --> | ||
<!--<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />--> | ||
</rule> | ||
</ruleset> |
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
Oops, something went wrong.