Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivopetkov committed Dec 30, 2018
0 parents commit e1a3276
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/README.md export-ignore
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vendor/
composer.lock
nbproject/
.idea/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Share button element
Element for Bear CMS
Binary file added assets/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

/*
* Share button element addon for Bear CMS
* https://github.com/bearcms/share-button-element-addon
* Copyright (c) Amplilabs Ltd.
* Free to use under the MIT license.
*/

BearFramework\Addons::register('bearcms/share-button-element-addon', __DIR__, [
'require' => [
'bearcms/bearframework-addon'
]
]);
17 changes: 17 additions & 0 deletions bearcms.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]",
"url": "https://bearcms.com/"
},
"media": [
{
"filename": "/assets/1.png",
"width": 1890,
"height": 1404
}
]
}
14 changes: 14 additions & 0 deletions components/shareButtonElement.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

use BearFramework\App;

$app = App::get();
$context = $app->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 '<component src="social-sharing-button" url="' . htmlentities($url) . '" class="bearcms-share-button-element"/>';
22 changes: 22 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]",
"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"]
}
}
43 changes: 43 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/*
* Share button element addon for Bear CMS
* https://github.com/bearcms/share-button-element-addon
* Copyright (c) Amplilabs Ltd.
* Free to use under the MIT license.
*/

use BearFramework\App;

$app = App::get();

$app->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"}'
]);
};
};
});

0 comments on commit e1a3276

Please sign in to comment.