Skip to content

Commit

Permalink
Merge pull request #1 from andrewandante/2
Browse files Browse the repository at this point in the history
SS4 compatibility
  • Loading branch information
andrewandante authored Dec 5, 2017
2 parents 8e31efc + d1be093 commit 76a8fe6
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 21 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ Alternatively, you can include `$WomensRefugeShieldButton` anywhere in your temp

![Button in the footer](img/screenshots/button_in_footer.PNG?raw=true)

## Versioning

- version 1.x is for SilverStripe 3
- version 2.x is for SilverStripe 4

# Options

You can view all the options on the [Women's Refuge Shielded Site website](https://shielded.co.nz/).


# TODO

- responsiveness
Expand Down
2 changes: 0 additions & 2 deletions _config.php
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
<?php

define('SS_WOMENS_REFUGE_DIR', basename(dirname(__FILE__)));
8 changes: 4 additions & 4 deletions _config/extensions.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SiteConfig:
SilverStripe\SiteConfig\SiteConfig:
extensions:
- WomensRefugeShieldSiteConfigExtension
ContentController:
- AndrewAndante\WomensRefugeShield\SiteConfigExtension
SilverStripe\CMS\Controllers\ContentController:
extensions:
- WomensRefugeShieldControllerExtension
- AndrewAndante\WomensRefugeShield\ControllerExtension
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
<?php

namespace AndrewAndante\WomensRefugeShield;

use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\Core\Extension;
use SilverStripe\SiteConfig\SiteConfig;
use SilverStripe\View\Requirements;


/**
* Class WomensRefugeShieldControllerExtension
* Class AndrewAndante\WomensRefugeShield\ControllerExtension
*
* @property ContentController $owner
*/
class WomensRefugeShieldControllerExtension extends Extension
class ControllerExtension extends Extension
{

public function onAfterInit()
{
$config = SiteConfig::current_site_config();
$jsDir = SS_WOMENS_REFUGE_DIR . DIRECTORY_SEPARATOR . 'javascript' . DIRECTORY_SEPARATOR;
switch ($config->ShieldCode) {
case 1:
Requirements::javascript('https://d3f5l8ze0o4j2m.cloudfront.net/m87/k33spt.js');
Requirements::javascript($jsDir.'large_tab.js');
Requirements::javascript('andrewandante/womens-refuge-shield: javascript/large_tab.js');
break;
case 2:
Requirements::javascript('https://d3f5l8ze0o4j2m.cloudfront.net/m87/k33spt.js');
Requirements::javascript($jsDir.'small_tab.js');
Requirements::javascript('andrewandante/womens-refuge-shield: javascript/small_tab.js');
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
<?php

namespace AndrewAndante\WomensRefugeShield;

use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\DataExtension;
use SilverStripe\SiteConfig\SiteConfig;

/**
* Class WomensRefugeShieldSiteConfigExtension
* Class AndrewAndante\WomensRefugeShield\SiteConfigExtension
*
* @property SiteConfig $owner
* @property int $Pridecode
*/
class WomensRefugeShieldSiteConfigExtension extends DataExtension
class SiteConfigExtension extends DataExtension
{

private static $db = array(
Expand Down
20 changes: 16 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "andrewandante/womens-refuge-shield",
"description": "Add the Women's refuge shield to your site",
"type": "silverstripe-module",
"type": "silverstripe-vendormodule",
"keywords": ["silverstripe", "womens", "women", "refuge", "shield"],
"license": "BSD-3-Clause",
"authors": [
Expand All @@ -13,8 +13,20 @@
],
"require":
{
"silverstripe/framework": "~3.0",
"silverstripe/siteconfig": "~3.0",
"silverstripe/cms": "~3.0"
"silverstripe/framework": "^4.0",
"silverstripe/siteconfig": "^4.0",
"silverstripe/cms": "^4.0"
},
"extra": {
"expose": [
"css",
"javascript",
"img/logos"
]
},
"autoload": {
"psr-4": {
"AndrewAndante\\WomensRefugeShield\\": "code/"
}
}
}
Binary file added img/logos/custom-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions templates/WomensRefugeShieldButton.ss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% require javascript("https://d3f5l8ze0o4j2m.cloudfront.net/m87/k33spt.js") %>
<% require javascript("womens-refuge-shield/javascript/button.js") %>
<% require css("womens-refuge-shield/css/button.css") %>
<% require javascript("andrewandante/womens-refuge-shield: javascript/button.js") %>
<% require css("andrewandante/womens-refuge-shield: css/button.css") %>

<a href="#" id="womens-refuge-shield-button">
<img src="womens-refuge-shield/img/custom-logo.png">
<img src="$ResourceURL(andrewandante/womens-refuge-shield: img/logos/custom-logo.png)">
</a>

0 comments on commit 76a8fe6

Please sign in to comment.