diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..35d4237 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +/.gitattributes export-ignore +/.gitignore export-ignore +/README.md export-ignore \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c21098d --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +vendor/ +composer.lock +nbproject/ +.idea/ \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..771a5e0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) Amplilabs Ltd. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..ca01d53 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Share button element +Element for Bear CMS diff --git a/assets/1.png b/assets/1.png new file mode 100644 index 0000000..d4b0329 Binary files /dev/null and b/assets/1.png differ diff --git a/autoload.php b/autoload.php new file mode 100644 index 0000000..c37bf83 --- /dev/null +++ b/autoload.php @@ -0,0 +1,14 @@ + [ + 'bearcms/bearframework-addon' + ] +]); diff --git a/bearcms.json b/bearcms.json new file mode 100644 index 0000000..e2701c6 --- /dev/null +++ b/bearcms.json @@ -0,0 +1,17 @@ +{ + "id": "bearcms/share-button-element-addon", + "name": "Share button element", + "description": "Enable support for share buttons in your website. Adding such elements to your website helps your visitors easily promote your content. A total share count (includes Facebook and LinkedIn) is available too.", + "author": { + "name": "Bear CMS", + "email": "support@bearcms.com", + "url": "https://bearcms.com/" + }, + "media": [ + { + "filename": "/assets/1.png", + "width": 1890, + "height": 1404 + } + ] +} \ No newline at end of file diff --git a/components/shareButtonElement.php b/components/shareButtonElement.php new file mode 100644 index 0000000..7af1b36 --- /dev/null +++ b/components/shareButtonElement.php @@ -0,0 +1,14 @@ +context->get(__FILE__); + +$url = (string) $component->url; +if ($url === 'home') { + $url = $app->urls->get(); +} elseif ($url === 'current') { + $url = $app->urls->get($app->request->path); +} +echo ''; diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..2d28de0 --- /dev/null +++ b/composer.json @@ -0,0 +1,22 @@ +{ + "name": "bearcms/share-button-element-addon", + "description": "Share button element for Bear CMS", + "keywords": ["share button", "element", "Bear CMS"], + "homepage": "https://github.com/bearcms/share-button-element-addon", + "license": "MIT", + "authors": [ + { + "name": "Bear CMS", + "email": "support@bearcms.com", + "homepage": "https://bearcms.com/" + } + ], + "require": { + "php": ">=7.1", + "bearcms/bearframework-addon": "^0.6.2", + "ivopetkov/social-sharing-bearframework-addon": "0.1.*" + }, + "autoload": { + "files": ["autoload.php"] + } +} diff --git a/index.php b/index.php new file mode 100644 index 0000000..990711b --- /dev/null +++ b/index.php @@ -0,0 +1,43 @@ +bearCMS->addons + ->announce('bearcms/share-button-element-addon', function(\BearCMS\Addons\Addon $addon) use ($app) { + $addon->initialize = function() use ($app) { + $context = $app->context->get(__FILE__); + + $context->assets->addDir('assets'); + + \BearCMS\Internal\ElementsTypes::add('shareButton', [ + 'componentSrc' => 'bearcms-share-button-element', + 'componentFilename' => $context->dir . '/components/shareButtonElement.php', + 'fields' => [ + [ + 'id' => 'url', + 'type' => 'textbox' + ] + ] + ]); + + \BearCMS\Internal\Themes::$elementsOptions['shareButton'] = function($context, $idPrefix, $parentSelector) { + $group = $context->addGroup('Share button'); + $group->addOption($idPrefix . "ShareButtonCSS", "css", '', [ + "cssOutput" => [ + ["rule", $parentSelector . " .bearcms-share-button-element", "cursor:pointer;display:inline-block;"], + ["selector", $parentSelector . " .bearcms-share-button-element"] + ], + "value" => '{"background-color":"#3374ce","border-top":"1px solid #3169c4","border-right":"1px solid #3169c4","border-bottom":"1px solid #3169c4","border-left":"1px solid #3169c4","font-size":"12px","font-family":"Arial","font-weight":"bold","height":"33px","line-height":"32px","padding-left":"10px","padding-right":"10px","color":"#ffffff","border-top-left-radius":"2px","border-top-right-radius":"2px","border-bottom-left-radius":"2px","border-bottom-right-radius":"2px"}' + ]); + }; + }; + });