-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8a65ebe
Showing
6 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "floriankarsten/kirby-plausible", | ||
"description": "", | ||
"type": "kirby-plugin", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Florian Karsten", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"getkirby/composer-installer": "^1.1", | ||
"php": ">=7.4.0" | ||
}, | ||
"autoload": { | ||
}, | ||
"config": { | ||
"optimize-autoloader": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
panel.plugin("floriankarsten/plausible", { | ||
views: { | ||
plausible: { | ||
label: 'Analytics', | ||
icon: "road-sign", | ||
component: { | ||
template: ` | ||
<div class="k-plausible-view"> | ||
<div style="margin-top: 30px; text-align: center;" v-if="showError"> | ||
<code>You need to set floriankarsten.plausible.sharedLink in config.php</code> | ||
</div> | ||
<iframe v-if="sharedLink" plausible-embed v-bind:src="sharedLink" scrolling="no" frameborder="0" loading="lazy" style="width: 1px; min-width: 100%; height: 1600px;"></iframe> | ||
</div>`, | ||
data: function() { | ||
return { | ||
options: {}, | ||
showError: false, | ||
sharedLink: "," | ||
}; | ||
}, | ||
created: function() { | ||
this.$api | ||
.get("plausible") | ||
.then(options => { | ||
if(!options.sharedLink) { | ||
this.showError = true; | ||
} else { | ||
this.sharedLink = options.sharedLink + "&embed=true&theme=light" | ||
} | ||
}); | ||
} | ||
}, | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
Kirby::plugin('floriankarsten/plausible', [ | ||
'api' => [ | ||
'routes' => [ | ||
[ | ||
'pattern' => 'plausible', | ||
'action' => function () { | ||
return option('floriankarsten.plausible'); | ||
} | ||
] | ||
] | ||
], | ||
'snippets' => [ | ||
'plausible' => __DIR__ . '/snippets/plausible.php' | ||
] | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Kirby Plausible | ||
Simple plugin providing plausible iframe panel view to kirby panel and simple frontend snippet. | ||
|
||
## How to use | ||
1. Create a shared link https://plausible.io/docs/shared-links | ||
2. Set `floriankarsten.plausible.shareLink` in config.php | ||
|
||
There is also `floriankarsten.plausible.domain` which allows you to overwrite `data-domain` in the frontend snippet. | ||
|
||
config.php example | ||
```php | ||
'floriankarsten.plausible' => [ | ||
'sharedLink' => 'https://plausible.io/share/yourwebsiteurl.com?auth=Jz0mCWTPu5opXi0sAgRrq', | ||
'domain' => 'test.com' // not required if not set it will be taken from $site->url | ||
]; | ||
``` | ||
|
||
Frontend snippet place iside head tag. Automatically disabled when kirby is in debug mode. | ||
```php | ||
<?php snippet('plausible'); ?> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php if(option('debug') === false): ?> | ||
<script async defer data-domain="<?= option('floriankarsten.plausible.domain') ?? parse_url($kirby->url('index'))['host'] ?>" src="https://plausible.io/js/plausible.js"></script> | ||
<?php endif; ?> |