Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
berrnd committed Apr 12, 2023
1 parent 11a5be8 commit 8c06ff5
Show file tree
Hide file tree
Showing 64 changed files with 5,122 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .devtools/create_release_package.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
set projectPath=%~dp0
if %projectPath:~-1%==\ set projectPath=%projectPath:~0,-1%
set projectPath=%projectPath%\..

set releasePath=%projectPath%\.release
mkdir "%releasePath%"

copy "%projectPath%\version.json" versiontemp.json
for /f "tokens=*" %%a in ('jq .Version versiontemp.json --raw-output') do set version=%%a
del versiontemp.json

del "%releasePath%\piksi_%version%.zip"
7za a -r "%releasePath%\piksi_%version%.zip" "%projectPath%\*" -xr!.* -xr!composer.json -xr!composer.lock -xr!package.json -xr!yarn.lock
7za a "%releasePath%\piksi_%version%.zip" "%projectPath%\public\.htaccess"
7za rn "%releasePath%\piksi_%version%.zip" .htaccess public\.htaccess
7za d "%releasePath%\piksi_%version%.zip" data\*.* data\viewcache\*
7za a "%releasePath%\piksi_%version%.zip" "%projectPath%\data\.htaccess"
7za rn "%releasePath%\piksi_%version%.zip" .htaccess data\.htaccess
4 changes: 4 additions & 0 deletions .devtools/install_dependencies.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pushd ..
call composer install
call yarn install
popd
4 changes: 4 additions & 0 deletions .devtools/update_dependencies.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pushd ..
call composer update
call yarn upgrade
popd
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
indent_style = tab
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto
*.sh text eol=lf
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom: ["https://berrnd.de/say-thanks?project=Piksi"]
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Bug Report
about: If you've found something that does not work, please report it to help improve
Piksi
title: 'Bug: '
labels: bug
assignees: ''

---

<!--
Please make sure to:
- Describe the bug as detailed as possible by providing the exact steps how to reproduce it
- Attach screenshots where useful
- Check if the problem was maybe already reported or fixed by searching open and closed issues here
-->
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: Feature Request
about: Ideas for improvements or new things which you would find useful are always
welcome
title: 'Feature Request: '
labels: enhancement
assignees: ''

---

<!--
Please make sure to:
- Describe what you would find useful
- Check if your idea was maybe already requested by searching open requests here
-->
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
name: Question
about: If you just have a question or need help
title: 'Question: '
labels: question
assignees: ''

---
Binary file added .github/publication_assets/album_with_albums.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/publication_assets/gallery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/publication_assets/overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/public/node_modules
/vendor
/.release
95 changes: 95 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php

$finder = PhpCsFixer\Finder::create()
->exclude(['vendor'])
->ignoreVCSIgnored(true)
->files()->name('*.php')
->in(__DIR__)
;

$cfg = new PhpCsFixer\Config();
return $cfg
->setRules([
'@PSR2' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_unsets' => true,
'class_attributes_separation' => true,
'multiline_whitespace_before_semicolons' => false,
'single_quote' => true,
// 'blank_line_after_opening_tag' => true,
// 'blank_line_before_return' => true,
'braces' => [
'allow_single_line_closure' => true,
'position_after_anonymous_constructs' => 'same',
'position_after_control_structures' => 'next',
'position_after_functions_and_oop_constructs' => 'next',
],
// 'cast_spaces' => true,
// 'class_definition' => array('singleLine' => true),
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => true,
'function_typehint_space' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],
'include' => true,
'lowercase_cast' => true,
// 'native_function_casing' => true,
// 'new_with_braces' => true,
// 'no_blank_lines_after_class_opening' => true,
// 'no_blank_lines_after_phpdoc' => true,
// 'no_empty_comment' => true,
// 'no_empty_phpdoc' => true,
// 'no_empty_statement' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
// 'no_mixed_echo_print' => array('use' => 'echo'),
'no_multiline_whitespace_around_double_arrow' => true,
// 'no_short_bool_cast' => true,
// 'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_around_offset' => true,
// 'no_trailing_comma_in_list_call' => true,
// 'no_trailing_comma_in_singleline_array' => true,
// 'no_unneeded_control_parentheses' => true,
// 'no_unused_imports' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
// 'normalize_index_brace' => true,
'object_operator_without_whitespace' => true,
// 'php_unit_fqcn_annotation' => true,
// 'phpdoc_align' => true,
// 'phpdoc_annotation_without_dot' => true,
// 'phpdoc_indent' => true,
// 'phpdoc_inline_tag' => true,
// 'phpdoc_no_access' => true,
// 'phpdoc_no_alias_tag' => true,
// 'phpdoc_no_empty_return' => true,
// 'phpdoc_no_package' => true,
// 'phpdoc_no_useless_inheritdoc' => true,
// 'phpdoc_return_self_reference' => true,
// 'phpdoc_scalar' => true,
// 'phpdoc_separation' => true,
// 'phpdoc_single_line_var_spacing' => true,
// 'phpdoc_summary' => true,
// 'phpdoc_to_comment' => true,
// 'phpdoc_trim' => true,
// 'phpdoc_types' => true,
// 'phpdoc_var_without_name' => true,
// 'pre_increment' => true,
// 'return_type_declaration' => true,
// 'self_accessor' => true,
// 'short_scalar_cast' => true,
'single_blank_line_before_namespace' => true,
// 'single_class_element_per_statement' => true,
// 'space_after_semicolon' => true,
// 'standardize_not_equals' => true,
'ternary_operator_spaces' => true,
// 'trailing_comma_in_multiline_array' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'whitespace_after_comma_in_array' => true,
])
->setIndent("\t")
->setLineEnding("\n")
->setUsingCache(false)
->setFinder($finder)
;
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"phpserver.relativePath": "public",
"editor.formatOnType": true,
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.insertSpaces": false,
"javascript.format.placeOpenBraceOnNewLineForControlBlocks": true,
"javascript.format.placeOpenBraceOnNewLineForFunctions": true,
"javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
"javascript.preferences.quoteStyle": "double",
"blade.format.enable": true,
"html.format.wrapAttributes": "force",
"html.format.wrapLineLength": 0,
"php-cs-fixer.formatHtml": true,
"php-cs-fixer.autoFixBySemicolon": true
}
4 changes: 4 additions & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--modules-folder public/node_modules
--install.production true
--install.ignore-scripts true
--install.ignore-optional true
95 changes: 94 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,94 @@
# piksi
<div align="center">
<img alt="Logo" height="50" src="https://raw.githubusercontent.com/berrnd/piksi/main/public/img/logo.svg?sanitize=true" />
<h4>A web-based self-hosted image gallery (viewer for an existing album based folder structure) focused on simplicity.<br>Created by <a href="https://github.com/berrnd">@berrnd</a></h4>
</div>

-----

## Give it a try

- Public demo of the latest stable version (`release` branch) &rarr; [https://piksi-demo.berrnd.de](https://piksi-demo.berrnd.de)

## Features / Motivation

Lately I've digitzed a large number of photos and wanted to make them accessible to older family members. There are a lot of web-based image galleries out there and I kind of tried them all, but none of them met my expectations of a simple user interface that would work for people who didn't grow up with computers.

I wanted to have a tool that

- displays pictures from an existing folder structure (one album per folder, unlimited subfolders are supported)
- uses the folder name for albums or alternatively a cover image (configurable naming convention)
- uses pre-generated thumbnails (from a subfolder per album, again configurable naming convention)
- has a strong focus on simplictiy - that explicitly means:
- no file management, sharing or similar gallery organization options (it's just a viewer)
- it doesn't show any technical information like file names or EXIF metadata
- it doesn't have user management (means no authentication, so run this in a trusted local network only)

to make those family memories of yesterday accessible on devices of today, but without the overly complex stuff which practically often discourages the mentioned target audience to have fun with modern things. I haven't found that, so this is Piksi.

## Questions / Help / Bug Reports / Feature Requests

Please use the [Issue Tracker](https://github.com/berrnd/piksi/issues/new/choose) for any requests.

## How to install

Piksi is technically a pretty simple PHP application, so the basic notes to get it running are:

- Unpack the [latest release ZIP](https://github.com/berrnd/piksi/releases/latest)
- Copy `config-dist.php` to `data/config.php` + edit to your needs (all config options should be self-explanatory based on the comments there)
- Ensure that the `data` directory is writable
- The webserver root should point to the `public` directory
- Include `try_files $uri /index.php$is_args$query_string;` in your location block if you use nginx
- Or disable URL rewriting (see the option `DISABLE_URL_REWRITING` in `data/config.php`)

Alternatively clone this repository (the `release` branch always references the latest released version) and install Composer and Yarn dependencies manually.

### Platform support

- PHP 8.1
- Required PHP extensions: `fileinfo`, `ctype`, `json`, `intl`, `zlib`, `mbstring`

## How to update

- Overwrite everything with the [latest release ZIP](https://github.com/berrnd/piksi/releases/latest) while keeping the `data` directory
- Check `config-dist.php` for new configuration options and add them to your `data/config.php` where appropriate (the default values from `config-dist.php` will be used for not in `data/config.php` defined settings)
- Empty the `data/viewcache` directory

## Localization

Piksi is fully localizable - the default language is English (integrated into code), a German localization is always maintained by me.

You can easily help translating Piksi:

- Copy `localization/en.po` to e.g. `localization/it.po` to start the italian translation
- Translate all strings (lines starting with `msgstr`) in the `.po` file
- Test it by changing the option `LOCALE` in `data/config.php`
- Submit a pull request if you want to have the translations included for everyone

## Things worth to know

### Adding your own CSS or JS without to have to modify the application itself

- When the file `data/custom_js.html` exists, the contents of the file will be added just before `</body>` (end of body) on every page
- When the file `data/custom_css.html` exists, the contents of the file will be added just before `</head>` (end of head) on every page

## Contributing / Say Thanks

Any help is welcome, feel free to contribute anything which comes to your mind or see [https://berrnd.de/say-thanks](https://berrnd.de/say-thanks?project=Piksi) if you just want to say thanks.

## Roadmap

There is none. The progress of a specific bug/enhancement is always tracked in the corresponding issue, at least by commit comment references.

## Screenshots

![overview](https://github.com/berrnd/piksi/raw/main/.github/publication_assets/overview.png "overview")

![album_with_albums](https://github.com/berrnd/piksi/raw/main/.github/publication_assets/album_with_albums.png "album_with_albums")

![gallery](https://github.com/berrnd/piksi/raw/main/.github/publication_assets/gallery.png "gallery")

![gallery_with_videos](https://github.com/berrnd/piksi/raw/main/.github/publication_assets/gallery_with_videos.png "gallery_with_videos")

## License

The MIT License (MIT)
87 changes: 87 additions & 0 deletions app.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php

use DI\Container as DIContainer;
use Piksi\Helpers\UrlManager;
use Piksi\Controllers\ExceptionController;
use Psr\Container\ContainerInterface as Container;
use Slim\Factory\AppFactory;
use Slim\Views\Blade;

// Check base requirements
require_once __DIR__ . '/helpers/RequirementsChecker.php';
$requirementsChecker = new Piksi\Helpers\RequirementsChecker();
try
{
$requirementsChecker->CheckEnvironment();
}
catch (\Exception $ex)
{
exit('Unable to run Piksi: ' . $ex->getMessage());
}

// Load composer dependencies
require_once __DIR__ . '/vendor/autoload.php';

// Load config files
require_once PIKSI_DATAPATH . '/config.php';
require_once __DIR__ . '/config-dist.php'; // For not in own config defined values we use the default ones

// Check required config options
try
{
$requirementsChecker->CheckConfig();
}
catch (\Exception $ex)
{
exit('Unable to run Piksi (config.php check failed): ' . $ex->getMessage());
}

// Error reporting definitions
if (PIKSI_MODE === 'dev')
{
error_reporting(E_ALL);
}
else
{
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING | E_DEPRECATED));
}

// Create data/viewcache folder if it doesn't exist
if (!file_exists(PIKSI_DATAPATH . '/viewcache'))
{
mkdir(PIKSI_DATAPATH . '/viewcache');
}

// Setup base application
AppFactory::setContainer(new DIContainer());
$app = AppFactory::create();

$container = $app->getContainer();
$container->set('view', function (Container $container) {
return new Blade(__DIR__ . '/views', PIKSI_DATAPATH . '/viewcache');
});

$container->set('UrlManager', function (Container $container) {
return new UrlManager(PIKSI_BASE_URL);
});

// Load routes from separate file
require_once __DIR__ . '/routes.php';

// Set base path if defined
if (!empty(PIKSI_BASE_PATH))
{
$app->setBasePath(PIKSI_BASE_PATH);
}

define('PIKSI_LOCALE', PIKSI_LOCALE);

// Add default middleware
$app->addRoutingMiddleware();
$errorMiddleware = $app->addErrorMiddleware(true, false, false);
$errorMiddleware->setDefaultErrorHandler(
new ExceptionController($app, $container)
);

ob_clean(); // No response output before here
$app->run();
Loading

0 comments on commit 8c06ff5

Please sign in to comment.