Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya committed Aug 21, 2016
2 parents 065cddc + 3b1545a commit 96faafd
Show file tree
Hide file tree
Showing 95 changed files with 2,263 additions and 424 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ build
composer.lock
vendor/
.env
data/database.sqlite
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
## CHANGELOG

### 1.2.0

**Features**

* [45: Allow to define tags on short codes, to improve filtering and classification](https://github.com/acelaya/url-shortener/issues/45)
* [7: Add website previews while listing available URLs](https://github.com/acelaya/url-shortener/issues/7)

**Enhancements:**

* [57: Add database migrations system to improve updating between versions](https://github.com/acelaya/url-shortener/issues/57)
* [31: Add support for other database management systems by improving the EntityManager factory](https://github.com/acelaya/url-shortener/issues/31)
* [51: Generate build process to paquetize the app and ease distribution](https://github.com/acelaya/url-shortener/issues/51)
* [38: Define installation script. It will request dynamic data on the fly so that there is no need to define env vars](https://github.com/acelaya/url-shortener/issues/38)

**Tasks**

* [55: Create update script which does not try to create a new database](https://github.com/acelaya/url-shortener/issues/55)
* [54: Add cache namespace to prevent name collisions with other apps in the same environment](https://github.com/acelaya/url-shortener/issues/54)
* [29: Use the acelaya/ze-content-based-error-handler package instead of custom error handler implementation](https://github.com/acelaya/url-shortener/issues/29)

**Bugs**

* [53: Fix entities database interoperability](https://github.com/acelaya/url-shortener/issues/53)
* [52: Add missing htaccess file for apache environments](https://github.com/acelaya/url-shortener/issues/52)

### 1.1.0

**Features**
Expand Down
8 changes: 1 addition & 7 deletions bin/cli
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@
<?php
use Interop\Container\ContainerInterface;
use Symfony\Component\Console\Application as CliApp;
use Symfony\Component\Console\Application;
use Zend\I18n\Translator\Translator;

/** @var ContainerInterface $container */
$container = include __DIR__ . '/../config/container.php';

/** @var Translator $translator */
$translator = $container->get('translator');
$translator->setLocale(env('CLI_LOCALE', 'en'));

/** @var Application $app */
/** @var CliApp $app */
$app = $container->get(CliApp::class);
$app->run();
14 changes: 14 additions & 0 deletions bin/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env php
<?php
use Shlinkio\Shlink\CLI\Command\Install\InstallCommand;
use Symfony\Component\Console\Application;
use Zend\Config\Writer\PhpArray;

chdir(dirname(__DIR__));

require __DIR__ . '/../vendor/autoload.php';

$app = new Application();
$app->add(new InstallCommand(new PhpArray()));
$app->setDefaultCommand('shlink:install');
$app->run();
14 changes: 14 additions & 0 deletions bin/update
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env php
<?php
use Shlinkio\Shlink\CLI\Command\Install\UpdateCommand;
use Symfony\Component\Console\Application;
use Zend\Config\Writer\PhpArray;

chdir(dirname(__DIR__));

require __DIR__ . '/../vendor/autoload.php';

$app = new Application();
$app->add(new UpdateCommand(new PhpArray()));
$app->setDefaultCommand('shlink:install');
$app->run();
Binary file added bin/wkhtmltoimage
Binary file not shown.
44 changes: 44 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
set -e

if [ "$#" -ne 1 ]; then
echo "Usage:" >&2
echo " $0 {version}" >&2
exit 1
fi

version=$1
builtcontent=$(readlink -f '../shlink_build_tmp')
projectdir=$(pwd)

# Copy project content to temp dir
echo 'Copying project files...'
rm -rf "${builtcontent}"
mkdir "${builtcontent}"
cp -R "${projectdir}"/* "${builtcontent}"
cd "${builtcontent}"

# Install dependencies
rm -r vendor
rm composer.lock
composer self-update
composer install --no-dev --optimize-autoloader

# Delete development files
echo 'Deleting dev files...'
rm build.sh
rm CHANGELOG.md
rm composer.*
rm LICENSE
rm php*
rm README.md
rm -r build
rm -f data/database.sqlite
rm -rf data/{cache,log,proxies}/{*,.gitignore}
rm -rf config/params/{*,.gitignore}
rm -rf config/autoload/{{,*.}local.php{,.dist},.gitignore}

# Compressing file
rm -f "${projectdir}"/build/shlink_${version}_dist.zip
zip -r "${projectdir}"/build/shlink_${version}_dist.zip .
rm -rf "${builtcontent}"
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@
"zendframework/zend-i18n": "^2.7",
"mtymek/expressive-config-manager": "^0.4",
"acelaya/zsm-annotated-services": "^0.2.0",
"acelaya/ze-content-based-error-handler": "^1.0",
"doctrine/orm": "^2.5",
"guzzlehttp/guzzle": "^6.2",
"symfony/console": "^3.0",
"symfony/process": "^3.0",
"symfony/filesystem": "^3.0",
"firebase/php-jwt": "^4.0",
"monolog/monolog": "^1.21",
"theorchard/monolog-cascade": "^0.4",
"endroid/qrcode": "^1.7"
"endroid/qrcode": "^1.7",
"mikehaertl/phpwkhtmltopdf": "^2.2",
"doctrine/migrations": "^1.4"
},
"require-dev": {
"phpunit/phpunit": "^5.0",
Expand Down
2 changes: 1 addition & 1 deletion config/autoload/app_options.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

'app_options' => [
'name' => 'Shlink',
'version' => '1.1.0',
'version' => '1.2.0',
'secret_key' => env('SECRET_KEY'),
],

Expand Down
2 changes: 0 additions & 2 deletions config/autoload/dependencies.global.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
use Shlinkio\Shlink\Common\ErrorHandler\ContentBasedErrorHandler;
use Zend\Expressive;
use Zend\Expressive\Container;
use Zend\Expressive\Router;
Expand All @@ -17,7 +16,6 @@
],
'aliases' => [
Router\RouterInterface::class => Router\FastRouteRouter::class,
'Zend\Expressive\FinalHandler' => ContentBasedErrorHandler::class,
],
],

Expand Down
2 changes: 1 addition & 1 deletion config/autoload/errorhandler.local.php.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
use Shlinkio\Shlink\Common\ErrorHandler\ContentBasedErrorHandler;
use Acelaya\ExpressiveErrorHandler\ErrorHandler\ContentBasedErrorHandler;
use Zend\Expressive\Container\WhoopsErrorHandlerFactory;

return [
Expand Down
11 changes: 11 additions & 0 deletions config/autoload/phpwkhtmltopdf.global.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
return [

'phpwkhtmltopdf' => [
'images' => [
'binary' => 'bin/wkhtmltoimage',
'type' => 'jpg',
],
],

];
8 changes: 8 additions & 0 deletions config/autoload/preview-generation.global.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
return [

'preview_generation' => [
'files_location' => 'data/cache',
],

];
9 changes: 5 additions & 4 deletions config/config.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
use Acelaya\ExpressiveErrorHandler;
use Shlinkio\Shlink\CLI;
use Shlinkio\Shlink\Common;
use Shlinkio\Shlink\Core;
use Shlinkio\Shlink\Rest;
use Zend\Expressive\ConfigManager\ConfigManager;
use Zend\Expressive\ConfigManager\ZendConfigProvider;
use Zend\Expressive\ConfigManager;

/**
* Configuration files are loaded in a specific order. First ``global.php``, then ``*.global.php``.
Expand All @@ -15,10 +15,11 @@
* Obviously, if you use closures in your config you can't cache it.
*/

return (new ConfigManager([
return (new ConfigManager\ConfigManager([
ExpressiveErrorHandler\ConfigProvider::class,
Common\ConfigProvider::class,
Core\ConfigProvider::class,
CLI\ConfigProvider::class,
Rest\ConfigProvider::class,
new ZendConfigProvider('config/autoload/{{,*.}global,{,*.}local}.php'),
new ConfigManager\ZendConfigProvider('config/{autoload/{{,*.}global,{,*.}local},params/generated_config}.php'),
], 'data/cache/app_config.php'))->getMergedConfig();
2 changes: 2 additions & 0 deletions config/params/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
39 changes: 39 additions & 0 deletions data/migrations/Version20160819142757.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace ShlinkMigrations;

use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;

/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20160819142757 extends AbstractMigration
{
const MYSQL = 'mysql';
const SQLITE = 'sqlite';

/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
$db = $this->connection->getDatabasePlatform()->getName();
$table = $schema->getTable('short_urls');
$column = $table->getColumn('short_code');

if ($db === self::MYSQL) {
$column->setPlatformOption('collation', 'utf8_bin');
} elseif ($db === self::SQLITE) {
$column->setPlatformOption('collate', 'BINARY');
}
}

/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
$db = $this->connection->getDatabasePlatform()->getName();
}
}
80 changes: 80 additions & 0 deletions data/migrations/Version20160820191203.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

namespace ShlinkMigrations;

use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;

/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20160820191203 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
// Check if the tables already exist
$tables = $schema->getTables();
foreach ($tables as $table) {
if ($table->getName() === 'tags') {
return;
}
}

$this->createTagsTable($schema);
$this->createShortUrlsInTagsTable($schema);
}

protected function createTagsTable(Schema $schema)
{
$table = $schema->createTable('tags');
$table->addColumn('id', Type::BIGINT, [
'unsigned' => true,
'autoincrement' => true,
'notnull' => true,
]);
$table->addColumn('name', Type::STRING, [
'length' => 255,
'notnull' => true,
]);
$table->addUniqueIndex(['name']);

$table->setPrimaryKey(['id']);
}

protected function createShortUrlsInTagsTable(Schema $schema)
{
$table = $schema->createTable('short_urls_in_tags');
$table->addColumn('short_url_id', Type::BIGINT, [
'unsigned' => true,
'notnull' => true,
]);
$table->addColumn('tag_id', Type::BIGINT, [
'unsigned' => true,
'notnull' => true,
]);

$table->addForeignKeyConstraint('tags', ['tag_id'], ['id'], [
'onDelete' => 'CASCADE',
'onUpdate' => 'RESTRICT',
]);
$table->addForeignKeyConstraint('short_urls', ['short_url_id'], ['id'], [
'onDelete' => 'CASCADE',
'onUpdate' => 'RESTRICT',
]);

$table->setPrimaryKey(['short_url_id', 'tag_id']);
}

/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
$schema->dropTable('short_urls_in_tags');
$schema->dropTable('tags');
}
}
4 changes: 4 additions & 0 deletions migrations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: ShlinkMigrations
migrations_namespace: ShlinkMigrations
table_name: migrations
migrations_directory: data/migrations
2 changes: 2 additions & 0 deletions module/CLI/config/cli.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
return [

'cli' => [
'locale' => env('CLI_LOCALE', 'en'),
'commands' => [
Command\Shortcode\GenerateShortcodeCommand::class,
Command\Shortcode\ResolveUrlCommand::class,
Command\Shortcode\ListShortcodesCommand::class,
Command\Shortcode\GetVisitsCommand::class,
Command\Shortcode\GeneratePreviewCommand::class,
Command\Visit\ProcessVisitsCommand::class,
Command\Config\GenerateCharsetCommand::class,
Command\Config\GenerateSecretCommand::class,
Expand Down
1 change: 1 addition & 0 deletions module/CLI/config/dependencies.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Command\Shortcode\ResolveUrlCommand::class => AnnotatedFactory::class,
Command\Shortcode\ListShortcodesCommand::class => AnnotatedFactory::class,
Command\Shortcode\GetVisitsCommand::class => AnnotatedFactory::class,
Command\Shortcode\GeneratePreviewCommand::class => AnnotatedFactory::class,
Command\Visit\ProcessVisitsCommand::class => AnnotatedFactory::class,
Command\Config\GenerateCharsetCommand::class => AnnotatedFactory::class,
Command\Config\GenerateSecretCommand::class => AnnotatedFactory::class,
Expand Down
Binary file modified module/CLI/lang/es.mo
Binary file not shown.
Loading

0 comments on commit 96faafd

Please sign in to comment.