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
1 parent
edf6a0e
commit f37a094
Showing
24 changed files
with
1,128 additions
and
3 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
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
10 changes: 10 additions & 0 deletions
10
module/VuFind/sql/migrations/pgsql/6.0/001-add-shortlinks-table.sql
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,10 @@ | ||
-- | ||
-- Table structure for table shortlinks | ||
-- | ||
|
||
CREATE TABLE shortlinks ( | ||
id SERIAL, | ||
path text, | ||
created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
PRIMARY KEY (id) | ||
); |
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
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
59 changes: 59 additions & 0 deletions
59
module/VuFind/src/VuFind/Controller/ShortlinkController.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,59 @@ | ||
<?php | ||
/** | ||
* Short link controller | ||
* | ||
* PHP version 7 | ||
* | ||
* Copyright (C) Villanova University 2019. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* @category VuFind | ||
* @package Controller | ||
* @author Demian Katz <demian.katz@villanova.edu> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://vufind.org Main Site | ||
*/ | ||
namespace VuFind\Controller; | ||
|
||
use VuFind\UrlShortener\UrlShortenerInterface; | ||
|
||
/** | ||
* Short link controller | ||
* | ||
* @category VuFind | ||
* @package Controller | ||
* @author Demian Katz <demian.katz@villanova.edu> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://vufind.org Main Site | ||
*/ | ||
class ShortlinkController extends AbstractBase | ||
{ | ||
/** | ||
* Resolve full version of shortlink & redirect to target. | ||
* | ||
* @return mixed | ||
*/ | ||
public function redirectAction() | ||
{ | ||
if ($id = $this->params('id')) { | ||
$resolver = $this->serviceLocator->get(UrlShortenerInterface::class); | ||
if ($url = $resolver->resolve($id)) { | ||
return $this->redirect()->toUrl($url); | ||
} | ||
} | ||
|
||
$this->getResponse()->setStatusCode(404); | ||
} | ||
} |
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
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,50 @@ | ||
<?php | ||
/** | ||
* Row Definition for shortlinks | ||
* | ||
* PHP version 7 | ||
* | ||
* Copyright (C) Villanova University 2019. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* @category VuFind | ||
* @package Db_Row | ||
* @author Demian Katz <demian.katz@villanova.edu> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://vufind.org Main Site | ||
*/ | ||
namespace VuFind\Db\Row; | ||
|
||
/** | ||
* Row Definition for shortlinks | ||
* | ||
* @category VuFind | ||
* @package Db_Row | ||
* @author Demian Katz <demian.katz@villanova.edu> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://vufind.org Main Site | ||
*/ | ||
class Shortlinks extends RowGateway | ||
{ | ||
/** | ||
* Constructor | ||
* | ||
* @param \Zend\Db\Adapter\Adapter $adapter Database adapter | ||
*/ | ||
public function __construct($adapter) | ||
{ | ||
parent::__construct('id', 'shortlinks', $adapter); | ||
} | ||
} |
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
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,58 @@ | ||
<?php | ||
/** | ||
* Table Definition for shortlinks | ||
* | ||
* PHP version 7 | ||
* | ||
* Copyright (C) Villanova University 2019. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* @category VuFind | ||
* @package Db_Table | ||
* @author Demian Katz <demian.katz@villanova.edu> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://vufind.org Main Site | ||
*/ | ||
namespace VuFind\Db\Table; | ||
|
||
use VuFind\Db\Row\RowGateway; | ||
use Zend\Db\Adapter\Adapter; | ||
|
||
/** | ||
* Table Definition for shortlinks | ||
* | ||
* @category VuFind | ||
* @package Db_Table | ||
* @author Demian Katz <demian.katz@villanova.edu> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://vufind.org Main Site | ||
*/ | ||
class Shortlinks extends Gateway | ||
{ | ||
/** | ||
* Constructor | ||
* | ||
* @param Adapter $adapter Database adapter | ||
* @param PluginManager $tm Table manager | ||
* @param array $cfg Zend Framework configuration | ||
* @param RowGateway $rowObj Row prototype object (null for default) | ||
* @param string $table Name of database table to interface with | ||
*/ | ||
public function __construct(Adapter $adapter, PluginManager $tm, $cfg, | ||
RowGateway $rowObj = null, $table = 'shortlinks' | ||
) { | ||
parent::__construct($adapter, $tm, $cfg, $rowObj, $table); | ||
} | ||
} |
Oops, something went wrong.