Skip to content

Commit

Permalink
Merge pull request #11 from tawk/release/pattern-matching
Browse files Browse the repository at this point in the history
Release/pattern matching
  • Loading branch information
pyhrus authored Apr 3, 2023
2 parents 6368cc0 + a2f0de1 commit a6becde
Show file tree
Hide file tree
Showing 14 changed files with 566 additions and 79 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: create-release-artifact

on:
release:
types: [published]

jobs:
create-release-artifact:
name: Creating release artifact
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2

- name: cached dependencies
uses: actions/cache@v2
id: cached-dependencies
with:
path: ./vendor
# the key will change if composer.lock changes
key: ${{ runner.os }}-dependencies-${{ hashFiles('**/composer.lock') }}

- name: install dependencies
uses: php-actions/composer@v6
with:
command: run build:prod

- name: version
id: version
run: echo "::set-output name=version::$(jq -r '.version' ./composer.json)"

- name: build artifacts
run: composer run package

- name: upload regular artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./tmp/tawk-oc3-${{ steps.version.outputs.version }}.zip
asset_name: tawk-oc3-${{ steps.version.outputs.version }}.zip
asset_content_type: application/zip

- name: upload ocmod artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./tmp/tawk-oc3-${{ steps.version.outputs.version }}.ocmod.zip
asset_name: tawk-oc3-${{ steps.version.outputs.version }}.ocmod.zip
asset_content_type: application/zip
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
upload/
*.zip
docker/bin
/vendor
/docker/bin
/tmp
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ This section describes how to install the plugin and get it working.
> If you aren’t using the English language for the OpenCart admin area, copy the language file into the correct language folder. If you are not using the default OpenCart theme, be sure to paste tawkto.twig in the correct theme folder.
* admin/controller/extension/module/tawkto.php -> `<opencart_folder>`/admin/controller/extension/module/
* admin/controller/extension/module/tawkto/ -> `<opencart_folder>`/admin/controller/extension/module/
* admin/language/en-gb/extension/module/tawkto.php -> `<opencart_folder>`/admin/language/`<your_language>`/extension/module/
* admin/view/image/tawkto/ -> `<opencart_folder>`/admin/view/image/
* admin/view/template/extension/module/tawkto.twig -> `<opencart_folder>`/admin/view/template/extension/module/
* admin/view/template/extension/module/tawkto/ -> `<opencart_folder>`/admin/view/template/extension/module/
* catalog/controller/extension/module/tawkto.php -> `<opencart_folder>`/catalog/controller/extension/module/tawkto.php
* catalog/view/theme/default/template/extension/module/tawkto.twig -> `<opencart_folder>`/catalog/view/theme/`<your_theme>`/template/extension/module/tawkto.twig

Expand All @@ -44,6 +46,9 @@ Visit our [Help Center](https://help.tawk.to/) for answers to FAQs

## Changelog

### 2.2.0
* Enhanced pattern matching for filtering pages to show/hide widgets.

### 2.1.1
* Added function for widget selection iframe to auto resize.
* Provided platform identifier to widget selection iframe.
Expand Down
21 changes: 20 additions & 1 deletion admin/controller/extension/module/tawkto.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/

define('PLUGIN_VERSION', '2.2.0');

require_once dirname(__FILE__) . '/tawkto/upgrades/manager.php';

class ControllerExtensionModuleTawkto extends Controller {
private $error = array();

Expand All @@ -29,6 +33,18 @@ public function index() {
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('setting/module');

// upgrade manager
$dependencies = array(
'model_setting' => $this->model_setting_setting,
'model_store' => $this->model_setting_store
);
$options = array(
'version' => PLUGIN_VERSION,
'version_var_name' => 'module_tawkto_version'
);
$upgrade_manager = new TawkToUpgradeManager($dependencies, $options);
$upgrade_manager->start();

$data = $this->setupIndexTexts();
$data['module_tawkto_status'] = $this->config->get('module_tawkto_status');

Expand Down Expand Up @@ -399,7 +415,10 @@ private function getBaseUrl() {

public function install() {
$this->setup();
$this->model_setting_setting->editSetting('module_tawkto', array("module_tawkto_status" => 1));
$this->model_setting_setting->editSetting('module_tawkto', array(
'module_tawkto_status' => 1,
'module_tawkto_version' => PLUGIN_VERSION
));
$this->enableAllLayouts();
}

Expand Down
119 changes: 109 additions & 10 deletions admin/view/template/extension/module/tawkto.twig
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,47 @@
margin-top: 1rem;
}
}
/* Tooltip */
.tawk-tooltip {
position: relative;
display: inline;
color: #03a84e;
}
.tawk-tooltip .tawk-tooltiptext {
visibility: hidden;
background-color: #545454;
color: #fff;
text-align: center;
padding: 0.5rem;
max-width: 300px;
border-radius: 0.5rem;
font-size: 1.2rem;
line-height: 1;
/* Position the tooltip text - see examples below! */
position: absolute;
z-index: 1000;
top: 12px;
}
.tawk-tooltip .tawk-tooltiptext::before {
content: "";
display: block;
width: 0;
height: 0;
position: absolute;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid #545454;
top: -5px;
left: 5px;
}
.tawk-tooltip:hover .tawk-tooltiptext {
visibility: visible;
}
</style>{{ column_left }}
<div id="content">
<div class="page-header">
Expand Down Expand Up @@ -159,13 +200,42 @@
<textarea class="form-control hide_specific" name="hide_oncustom" id="hide_oncustom" cols="30" rows="10"></textarea>
{% else %}
<textarea class="form-control hide_specific" name="hide_oncustom"
id="hide_oncustom" cols="30" rows="10">{% for page in hide_whitelist %}{{page}}{% endfor %}</textarea>
id="hide_oncustom" cols="30" rows="10">{% for page in hide_whitelist %}{{page ~ '\r\n'}}{% endfor %}</textarea>
{% endif %}
<br>
<p class="justify">
Add URLs to pages in which you would like to hide the widget. ( if "always show" is checked )<br>
Put each URL in a new line.
</p>
<div class="justify">
Add URLs/paths to pages in which you would like to hide the widget. ( if "always show" is checked )<br>
Put each URL/path in a new line. Paths should have a leading '/'.
<br>
<div class="tawk-tooltip">
Examples of accepted path patterns
<ul class="tawk-tooltiptext">
<li>*</li>
<li>*/to/somewhere</li>
<li>/*/to/somewhere</li>
<li>/path/*/somewhere</li>
<li>/path/*/lead/*/somewhere</li>
<li>/path/*/*/somewhere</li>
<li>/path/to/*</li>
<li>/path/to/*/</li>
<li>*/to/*/page</li>
<li>/*/to/*/page</li>
<li>/path/*/other/*</li>
<li>/path/*/other/*/</li>
<li>http://www.example.com/</li>
<li>http://www.example.com/*</li>
<li>http://www.example.com/*/to/somewhere</li>
<li>http://www.example.com/path/*/somewhere</li>
<li>http://www.example.com/path/*/lead/*/somewhere</li>
<li>http://www.example.com/path/*/*/somewhere</li>
<li>http://www.example.com/path/to/*</li>
<li>http://www.example.com/path/to/*/</li>
<li>http://www.example.com/*/to/*/page</li>
<li>http://www.example.com/path/*/other/*</li>
<li>http://www.example.com/path/*/other/*/</li>
</ul>
</div>
</div>
</div>
</div>
<div class="form-group col-lg-12">
Expand All @@ -190,13 +260,42 @@
<textarea class="form-control show_specific" name="show_oncustom" id="show_oncustom" cols="30" rows="10"></textarea>
{% else %}
<textarea class="form-control show_specific" name="show_oncustom"
id="show_oncustom" cols="30" rows="10">{% for page in show_whitelist %}{{page}}{% endfor %}</textarea>
id="show_oncustom" cols="30" rows="10">{% for page in show_whitelist %}{{page ~ '\r\n'}}{% endfor %}</textarea>
{% endif %}
<br>
<p class="justify">
Add URLs to pages in which you would like to show the widget.<br>
Put each URL in a new line.
</p>
<div class="justify">
Add URLs/paths to pages in which you would like to show the widget.<br>
Put each URL/path in a new line. Paths should have a leading '/'.
<br>
<div class="tawk-tooltip">
Examples of accepted path patterns
<ul class="tawk-tooltiptext">
<li>*</li>
<li>*/to/somewhere</li>
<li>/*/to/somewhere</li>
<li>/path/*/somewhere</li>
<li>/path/*/lead/*/somewhere</li>
<li>/path/*/*/somewhere</li>
<li>/path/to/*</li>
<li>/path/to/*/</li>
<li>*/to/*/page</li>
<li>/*/to/*/page</li>
<li>/path/*/other/*</li>
<li>/path/*/other/*/</li>
<li>http://www.example.com/</li>
<li>http://www.example.com/*</li>
<li>http://www.example.com/*/to/somewhere</li>
<li>http://www.example.com/path/*/somewhere</li>
<li>http://www.example.com/path/*/lead/*/somewhere</li>
<li>http://www.example.com/path/*/*/somewhere</li>
<li>http://www.example.com/path/to/*</li>
<li>http://www.example.com/path/to/*/</li>
<li>http://www.example.com/*/to/*/page</li>
<li>http://www.example.com/path/*/other/*</li>
<li>http://www.example.com/path/*/other/*/</li>
</ul>
</div>
</div>
</div>
</div>
<br></br>
Expand Down
34 changes: 17 additions & 17 deletions build-package.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
#!/bin/sh

if [ -z "$1" ]
then
echo "Release version wasn't specified";
return;
fi
release_version=$(jq -r '.version' ./composer.json);

release_version=$1;
echo "Creating temporary directory"
rm -rf ./tmp;
mkdir -p ./tmp/upload;
mkdir -p ./tmp/admin/controller/extension/module/tawkto;
mkdir -p ./tmp/catalog/controller/extension/module/tawkto;

echo "Creating temporary upload directory"
rm -rf ./upload
mkdir ./upload

echo "Copying files to upload directory"
cp -r admin ./upload/
cp -r catalog ./upload/
echo "Copying files"
cp README.md ./tmp;
cp -r admin ./tmp;
cp -r catalog ./tmp;
cp -r upgrades ./tmp/admin/controller/extension/module/tawkto;
cp -r vendor ./tmp/admin/controller/extension/module/tawkto;
cp -r vendor ./tmp/catalog/controller/extension/module/tawkto;
cp -r ./tmp/admin ./tmp/upload;
cp -r ./tmp/catalog ./tmp/upload;

echo "Creating opencart 3 zip files"
zip -9 -rq tawk-oc3-$release_version.ocmod.zip upload README.md
zip -9 -rq tawk-oc3-$release_version.zip admin catalog README.md

echo "Cleaning up"
rm -rf ./upload
$(cd ./tmp && zip -9 -rq tawk-oc3-$release_version.ocmod.zip upload README.md);
$(cd ./tmp && zip -9 -rq tawk-oc3-$release_version.zip admin catalog README.md);

echo "Done!"
Loading

0 comments on commit a6becde

Please sign in to comment.