Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
*.module linguist-language=php
*.inc linguist-language=php

/.gitignore export-ignore
/.github export-ignore
/composer.json export-ignore
/composer.lock export-ignore
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/libraries/composer/
/tmp/
17 changes: 17 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "tawk/tawk-backdrop",
"description": "tawk.to Live Chat module for Backdrop CMS",
"type": "project",
"license": "GPLv3",
"require": {
"tawk/url-utils": "2.0.1"
},
"config": {
"vendor-dir": "libraries"
},
"scripts": {
"build:prod": "composer install --no-dev --no-autoloader --no-scripts",
"package": "composer run clean && mkdir -p ./tmp/tawk_to && cp -r ./css ./tmp/tawk_to && cp -r ./includes ./tmp/tawk_to && cp -r ./js ./tmp/tawk_to && cp -r ./libraries ./tmp/tawk_to && cp ./tawk_to.* ./tmp/tawk_to && cp README.md ./tmp/tawk_to && cp LICENSE.txt ./tmp/tawk_to && (cd ./tmp && zip -9 -rq ./tawk_to.zip ./tawk_to)",
"clean": "rm -rf ./tmp"
}
}
68 changes: 68 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 43 additions & 1 deletion css/tawk_to.admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

/**
* Notification
* Notification
* Initially hide the status message. Jquery is used to show after updating settings
*/
.success-message-container {
Expand All @@ -22,3 +22,45 @@
border: none;
margin: 5px 0;
}

/* Tooltip */
.tooltip {
position: relative;
display: inline;
color: #03a84e;
font-size: 16px;
}

.tooltip .tooltiptext {
visibility: hidden;
background-color: #545454;
color: #fff;
text-align: center;
padding: 0.5rem;
max-width: 300px;
border-radius: 0.5rem;
font-size: 0.8rem;
line-height: 0.9;

/* Position the tooltip text - see examples below! */
position: absolute;
z-index: 1000;
top: 14px;
}

.tooltip .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;
}

.tooltip:hover .tooltiptext {
visibility: visible;
}
22 changes: 22 additions & 0 deletions libraries/tawk/url-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 2.0.1

Fixed compatibility issue for PHP version >= 5.6.

# 2.0.0

## General changes

- [Breaking] Removed old matching modules.
- `Tawk\Match\Path`
- `Tawk\Match\Url`
- Added new modules for pattern matching.
- `Tawk\Modules\PathPatternMatcher`
- `Tawk\Modules\UrlPatternMatcher`
- Added new helpers for parsing URLs and paths.
- `Tawk\Helpers\PathHelper`
- `Tawk\Helpers\UrlHelper`
- Added new enum `Tawk\Enums\WildcardLocation`.

# 1.0.0

Initial Release
82 changes: 82 additions & 0 deletions libraries/tawk/url-utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Tawk URL Utils Module

## Overview

A tawk.to utility library for URLs.

## Modules

### Url Pattern Matcher

This module handles matching of the provided URL to the provided patterns.

#### match(string $current_url, array $patterns)

Matches the provided url and patterns. Returns `true` if it matches. Otherwise, `false`.

##### Example

```php
<?php
use Tawk\Modules\UrlPatternMatcher;

$current_url = 'http://www.example.com/path/to/somewhere';
$patterns = array('http://www.example.com/path/to/somewhere');

$match_result = UrlPatternMatcher::match($current_url, $patterns);
```

### Path Pattern Matcher

This module handles matching of the provided URL path to the provided patterns by matching them per chunk.

#### match(array $current_path_chunks, array $path_patterns)

Matches the provided url path and patterns. Returns `true` if it matches. Otherwise, `false`.

```php
<?php
use Tawk\Helpers\PathHelper;
use Tawk\Models\PathPattern;
use Tawk\Modules\PathPatternMatcher;

$current_url = PathHelper::get_chunks('/path/to/somewhere');
$path_patterns = array(
PathPattern::create_instance_from_path('/path/to/somewhere'),
);

$match_result = PathPatternMatcher::match($current_url, $path_patterns);
```

### Additional Info

#### Valid Patterns for Pattern Matchers

- `*`
- `*/to/somewhere`
- `/*/to/somewhere`
- `/path/*/somewhere`
- `/path/*/lead/*/somewhere`
- `/path/*/*/somewhere`
- `/path/to/*`
- `/path/to/*/`
- `*/to/*/page`
- `/*/to/*/page`
- `/path/*/other/*`
- `/path/*/other/*/`
- `http://www.example.com/`
- `http://www.example.com/*`
- `http://www.example.com/*/to/somewhere`
- `http://www.example.com/path/*/somewhere`
- `http://www.example.com/path/*/lead/*/somewhere`
- `http://www.example.com/path/*/*/somewhere`
- `http://www.example.com/path/to/*`
- `http://www.example.com/path/to/*/`
- `http://www.example.com/*/to/*/page`
- `http://www.example.com/path/*/other/*`
- `http://www.example.com/path/*/other/*/`

#### Invalid Patterns for Pattern Matchers

- `path/*/somewhere` - "path" will be considered as a host and not a start of a path.
- `*/should/*/to/*` - This is currently not supported. Multiple wildcards on the pattern only supports either at `START and MIDDLE` or `MIDDLE and END` of the path.
27 changes: 27 additions & 0 deletions libraries/tawk/url-utils/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "tawk/url-utils",
"type": "library",
"require-dev": {
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.6",
"phpcompatibility/php-compatibility": "^9.3"
},
"version" : "2.0.1",
"autoload": {
"psr-4": {
"Tawk\\": "lib",
"Tawk\\Tests\\": "tests"
}
},
"scripts": {
"post-install-cmd": [
"([ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/phpcs --config-set installed_paths vendor/phpcompatibility/php-compatibility)"
],
"post-update-cmd": [
"([ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/phpcs --config-set installed_paths vendor/phpcompatibility/php-compatibility)"
],
"test": "phpunit",
"lint": "phpcs -p -s -v --runtime-set ignore_warnings_on_exit true .",
"lint:fix": "phpcbf -p -s -v .; err=$?; if [ $err -eq 1 ]; then exit 0; else exit $err; fi;"
}
}
Loading