Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMuller committed Dec 15, 2014
0 parents commit 1f36be4
Show file tree
Hide file tree
Showing 18 changed files with 917 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
custom/*.js
custom/*.css
custom/*.png
custom/*.svg
custom/*.gif
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Koken Photoswipe Plugin
=======================

Usage limitations
-----------------
This plugin is originally developped for the Axis Theme. It should work fine on Axis2 too. On other Themes, the result can be totally unpredictable.
It makes only sense on pages with a thumnail-grid layout and with the ability to link the images to Lightbox (lens templates using `<koken:link lightbox="true" ><koken:img /></koken:link>`).
Therefore this plugin is only used on *album*, *contents* and *favorites* page types.

Demo
----
Check out http://daniel.mesphotos.ch to see it in action

Installation
------------
[Photoswipe](https://github.com/dimsemenov/photoswipe) files are included as static inside the *vendor* folder.
To install, execute on the server (or locally and copy to the server):
```bash
git clone https://github.com/DanielMuller/koken-plugin-photoswipe.git path/to/koken/storage/plugins/photoswipe
```

Enable plugin in Settings/Plugins.

Configuration
-------------
There is no plugin configuration. But it advised to clear *System Caches* after inabling it.

Layout
------
By default, the default layout from Photoswipe is used:
- pswp/photoswipe.css
- pswp/default-skin/default-skin.css
- pswp/photoswipe.min.js
- pswp/photoswipe-ui-default.min.js
- pswp.min.js

You can replace any of this files, by creating a file with same name inside the `custom` folder:
- custom/photoswipe.css
- custom/default-skin/default-skin.css
- custom/photoswipe.min.js
- custom/photoswipe-ui-default.min.js
- custom/pswp.min.js

Todo
----
- Ajax/PHP calls for image details

Credits
-------
All the heavy lifting is done using [Photoswipe](http://photoswipe.com) by [Code computerlove](http://www.codecomputerlove.com/) and [Dmitry Semenov](http://dimsemenov.com/).
This plugin just integrates the relevant code into [Koken](http://koken.me/).
The version used in this plugin is [e5daa...](https://github.com/dimsemenov/PhotoSwipe/tree/e5daa8ab462697f3cb211715b788d8e1de78d98f)
Empty file added custom/.placeholder
Empty file.
Empty file.
10 changes: 10 additions & 0 deletions plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "PhotoSwipe",
"version": "1.0",
"description": "Replaces default Lightbox with Photoswipe (http://photoswipe.com)",
"author": {
"name": "Daniel Muller",
"link": "http://daniel.ctrlaltdel.ch"
}
}

52 changes: 52 additions & 0 deletions plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

class MesphotosPhotoswipe extends KokenPlugin {

function __construct()
{
$this->pswp_folder = "pswp";
$this->custom_folder = "custom";

$this->register_hook('before_closing_body', 'foot');
}

function foot($data)
{
$valid_page_classes = ["album", "contents", "favorites"];
$expr = strtolower(implode('|',$valid_page_classes));
$pattern = '/-('.$expr.').*\s.*-('.$expr.')/';
$valid_page = (preg_match($pattern,Koken::$page_class))==1 ? true : false;

if ($valid_page) {
$css = "photoswipe.css";
$skin_css = "default-skin/default-skin.css";
$js = "photoswipe.min.js";
$ui_js = "photoswipe-ui-default.min.js";
$pswp_js = "pswp.min.js";

$pswp[] = '<link rel="stylesheet" href="'.$this->get_url($css).'" />';
$pswp[] = '<link rel="stylesheet" href="'.$this->get_url($skin_css).'" />';
$pswp[] = '<script src="'.$this->get_url($js).'"></script>';
$pswp[] = '<script src="'.$this->get_url($ui_js).'"></script>';
$pswp[] = '<script src="'.$this->get_url($pswp_js).'"></script>';
$pswp[] = '<style type="text/css">.pswp {text-align:left;}</style>';
$pswp[] = '<script language="javascript">$(function(){initPhotoSwipeFromDOM();});</script>';

if (is_file($this->get_file_path().DIRECTORY_SEPARATOR.$this->custom_folder.DIRECTORY_SEPARATOR."pswp.html")) {
include $this->get_file_path().DIRECTORY_SEPARATOR.$this->custom_folder.DIRECTORY_SEPARATOR."pswp.html";
} else {
include $this->get_file_path().DIRECTORY_SEPARATOR.$this->pswp_folder.DIRECTORY_SEPARATOR."pswp.html";
}
print join("\n",$pswp);
}
}

function get_url($file) {
if (is_file($this->get_file_path().DIRECTORY_SEPARATOR.$this->custom_folder.DIRECTORY_SEPARATOR.$file)) {
return Koken::$location['real_root_folder']."/storage/plugins/".$this->get_key()."/".$this->custom_folder."/".$file;
}
else {
return Koken::$location['real_root_folder']."/storage/plugins/".$this->get_key()."/".$this->pswp_folder."/".$file;
}
}
}
Empty file added pswp/.placeholder
Empty file.
Loading

0 comments on commit 1f36be4

Please sign in to comment.