mirror of
https://github.com/AzuraCast/AzuraCast.git
synced 2024-06-14 13:16:37 +00:00
Generate and parse short URLs for convention archive pages.
This commit is contained in:
parent
3e6a064b50
commit
51c8aa2276
|
@ -146,6 +146,7 @@ class Convention extends \DF\Doctrine\Entity
|
|||
|
||||
$coverage = self::getCoverageLevels();
|
||||
array_walk($conventions, function(&$row, $key) use ($coverage) {
|
||||
$row['short_name'] = self::getConventionShortName($row['name']);
|
||||
$row['images'] = self::getImages($row);
|
||||
$row['range'] = self::getDateRange($row['start_date'], $row['end_date']);
|
||||
$row['coverage'] = $coverage[$row['coverage_level']];
|
||||
|
@ -164,6 +165,7 @@ class Convention extends \DF\Doctrine\Entity
|
|||
|
||||
$coverage = self::getCoverageLevels();
|
||||
array_walk($conventions, function(&$row, $key) use ($coverage) {
|
||||
$row['short_name'] = self::getConventionShortName($row['name']);
|
||||
$row['images'] = self::getImages($row);
|
||||
$row['range'] = self::getDateRange($row['start_date'], $row['end_date']);
|
||||
$row['coverage'] = $coverage[$row['coverage_level']];
|
||||
|
@ -172,6 +174,22 @@ class Convention extends \DF\Doctrine\Entity
|
|||
return $conventions;
|
||||
}
|
||||
|
||||
public static function getShortNameLookup()
|
||||
{
|
||||
$short_names = array();
|
||||
$archived_conventions = self::getConventionsWithArchives();
|
||||
|
||||
foreach($archived_conventions as $con)
|
||||
$short_names[$con['short_name']] = $con;
|
||||
|
||||
return $short_names;
|
||||
}
|
||||
|
||||
public static function getConventionShortName($name)
|
||||
{
|
||||
return strtolower(preg_replace("/[^A-Za-z0-9_]/", '', str_replace(' ', '_', $name)));
|
||||
}
|
||||
|
||||
public static function getImages($row)
|
||||
{
|
||||
if (isset($row['image_url']))
|
||||
|
|
|
@ -91,6 +91,12 @@ class ShortUrl extends \DF\Doctrine\Entity
|
|||
if (isset($station_urls[$origin]))
|
||||
return $station_urls[$origin];
|
||||
|
||||
// Check for a convention archive page (overrides manual input URLs).
|
||||
$convention_urls = self::conventionUrls();
|
||||
|
||||
if (isset($convention_urls[$origin]))
|
||||
return $convention_urls[$origin];
|
||||
|
||||
// Check for a matching URL.
|
||||
$url = self::getRepository()->findOneBy(array('short_url' => $origin));
|
||||
|
||||
|
@ -103,21 +109,39 @@ class ShortUrl extends \DF\Doctrine\Entity
|
|||
|
||||
public static function stationUrls()
|
||||
{
|
||||
$station_urls = array();
|
||||
$station_short_names = Station::getShortNameLookup();
|
||||
$urls = array();
|
||||
$short_names = Station::getShortNameLookup();
|
||||
|
||||
foreach($station_short_names as $short_name => $station)
|
||||
foreach($short_names as $short_name => $record)
|
||||
{
|
||||
$station_urls[$short_name] = \DF\Url::route(array(
|
||||
$urls[$short_name] = \DF\Url::route(array(
|
||||
'module' => 'default',
|
||||
'controller' => 'index',
|
||||
'action' => 'index',
|
||||
'id' => $station['id'],
|
||||
'id' => $record['id'],
|
||||
'autoplay' => 'true',
|
||||
));
|
||||
}
|
||||
|
||||
return $station_urls;
|
||||
return $urls;
|
||||
}
|
||||
|
||||
public static function conventionUrls()
|
||||
{
|
||||
$urls = array();
|
||||
$short_names = Convention::getShortNameLookup();
|
||||
|
||||
foreach($short_names as $short_name => $record)
|
||||
{
|
||||
$urls[$short_name] = \DF\Url::route(array(
|
||||
'module' => 'default',
|
||||
'controller' => 'convention',
|
||||
'action' => 'index',
|
||||
'id' => $record['id'],
|
||||
));
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
|
||||
public static function stationUrl(Station $station)
|
||||
|
|
|
@ -40,6 +40,8 @@ class Api_DevController extends \PVL\Controller\Action\Api
|
|||
'podcast',
|
||||
'podcast_on_station',
|
||||
'songs',
|
||||
'conventions',
|
||||
'convention_archives',
|
||||
);
|
||||
|
||||
// Compose mysqldump command.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
use \Entity\Station;
|
||||
use \Entity\Convention;
|
||||
use \Entity\ShortUrl;
|
||||
|
||||
class Stations_UrlsController extends \PVL\Controller\Action\Station
|
||||
|
@ -12,10 +13,11 @@ class Stations_UrlsController extends \PVL\Controller\Action\Station
|
|||
|
||||
$this->view->urls = $urls;
|
||||
|
||||
// Auto-Generated Station URLs.
|
||||
$station_details = Station::getShortNameLookup();
|
||||
$station_categories = Station::getCategories();
|
||||
|
||||
$station_urls = array();
|
||||
|
||||
foreach($station_details as $short_name => $station)
|
||||
{
|
||||
$station['url'] = ShortUrl::getFullUrl($short_name);
|
||||
|
@ -25,6 +27,18 @@ class Stations_UrlsController extends \PVL\Controller\Action\Station
|
|||
}
|
||||
|
||||
$this->view->station_urls = $station_urls;
|
||||
|
||||
// Auto-Generated Convention Archive URLs
|
||||
$convention_details = Convention::getShortNameLookup();
|
||||
$convention_urls = array();
|
||||
|
||||
foreach($convention_details as $short_name => $convention)
|
||||
{
|
||||
$convention['url'] = ShortUrl::getFullUrl($short_name);
|
||||
$convention_urls[$short_name] = $convention;
|
||||
}
|
||||
|
||||
$this->view->convention_urls = $convention_urls;
|
||||
}
|
||||
|
||||
public function editAction()
|
||||
|
|
|
@ -1,87 +1,108 @@
|
|||
<?php
|
||||
$this->headTitle('URL Shortener Management');
|
||||
$this->layout()->manual = true;
|
||||
|
||||
echo $this->renderHere('stationname', true);
|
||||
echo $this->renderHere('homelink', true);
|
||||
?>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span7">
|
||||
<h2>My Station's Links</h2>
|
||||
<h2>My Station's Links</h2>
|
||||
|
||||
<div class="buttons">
|
||||
<?=$this->button(array(
|
||||
'type' => 'link',
|
||||
'class' => 'btn-large success',
|
||||
'href' => $this->routeFromHere(array('action' => 'edit')),
|
||||
'icon' => 'icon-plus-sign',
|
||||
'text' => 'Add New URL',
|
||||
)) ?>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<?=$this->button(array(
|
||||
'type' => 'link',
|
||||
'class' => 'btn-large success',
|
||||
'href' => $this->routeFromHere(array('action' => 'edit')),
|
||||
'icon' => 'icon-plus-sign',
|
||||
'text' => 'Add New URL',
|
||||
)) ?>
|
||||
</div>
|
||||
|
||||
<table class="table table-striped table-bordered table-condensed">
|
||||
<colgroup>
|
||||
<col width="20%" />
|
||||
<col width="40%" />
|
||||
<col width="40%" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Actions</th>
|
||||
<th>Short URL</th>
|
||||
<th>Long URL</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<? foreach($this->urls as $record): ?>
|
||||
<tr class="input">
|
||||
<td class="center">
|
||||
<div class="btn-group">
|
||||
<?=$this->button(array(
|
||||
'type' => 'link',
|
||||
'href' => $this->routeFromHere(array('action' => 'edit', 'id' => $record['id'])),
|
||||
'icon' => 'icon-pencil',
|
||||
'text' => 'Edit',
|
||||
)) ?>
|
||||
<?=$this->button(array(
|
||||
'type' => 'link',
|
||||
'class' => 'btn-danger confirm-action',
|
||||
'href' => $this->routeFromHere(array('action' => 'delete', 'id' => $record['id'])),
|
||||
'icon' => 'icon-trash',
|
||||
'text' => 'Delete',
|
||||
)) ?>
|
||||
</div>
|
||||
</td>
|
||||
<td><a href="<?=$record->getUrl() ?>" target="_blank"><?=$record->getUrl() ?></a></td>
|
||||
<td><a href="<?=$record->long_url ?>" target="_blank"><?=$record->long_url ?></a></td>
|
||||
</tr>
|
||||
<? endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="span5">
|
||||
<h2>System-Wide Short URLs</h2>
|
||||
<table class="table table-striped table-bordered table-condensed">
|
||||
<colgroup>
|
||||
<col width="20%" />
|
||||
<col width="40%" />
|
||||
<col width="40%" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Actions</th>
|
||||
<th>Short URL</th>
|
||||
<th>Long URL</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<? foreach($this->urls as $record): ?>
|
||||
<tr class="input">
|
||||
<td class="center">
|
||||
<div class="btn-group">
|
||||
<?=$this->button(array(
|
||||
'type' => 'link',
|
||||
'href' => $this->routeFromHere(array('action' => 'edit', 'id' => $record['id'])),
|
||||
'icon' => 'icon-pencil',
|
||||
'text' => 'Edit',
|
||||
)) ?>
|
||||
<?=$this->button(array(
|
||||
'type' => 'link',
|
||||
'class' => 'btn-danger confirm-action',
|
||||
'href' => $this->routeFromHere(array('action' => 'delete', 'id' => $record['id'])),
|
||||
'icon' => 'icon-trash',
|
||||
'text' => 'Delete',
|
||||
)) ?>
|
||||
</div>
|
||||
</td>
|
||||
<td><a href="<?=$record->getUrl() ?>" target="_blank"><?=$record->getUrl() ?></a></td>
|
||||
<td><a href="<?=$record->long_url ?>" target="_blank"><?=$record->long_url ?></a></td>
|
||||
</tr>
|
||||
<? endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table class="table table-striped table-bordered table-condensed">
|
||||
<colgroup>
|
||||
<col width="40%" />
|
||||
<col width="60%" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Station Name</th>
|
||||
<th>Station URL</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<? foreach($this->station_urls as $record): ?>
|
||||
<tr class="input">
|
||||
<td><i class="<?=$record['icon'] ?>"></i> <?=$record['name'] ?></td>
|
||||
<td><a href="<?=$record['url'] ?>" target="_blank"><?=$record['url'] ?></a></td>
|
||||
</tr>
|
||||
<? endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<h2>System-Wide Short URLs</h2>
|
||||
|
||||
<h3>Stations</h3>
|
||||
<p>These URLs link to the Ponyville Live! homepage and auto-play the specified station.</p>
|
||||
|
||||
<table class="table table-striped table-bordered table-condensed">
|
||||
<colgroup>
|
||||
<col width="40%" />
|
||||
<col width="60%" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Station Name</th>
|
||||
<th>Station URL</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<? foreach($this->station_urls as $record): ?>
|
||||
<tr class="input">
|
||||
<td><i class="<?=$record['icon'] ?>"></i> <?=$record['name'] ?></td>
|
||||
<td><a href="<?=$record['url'] ?>" target="_blank"><?=$record['url'] ?></a></td>
|
||||
</tr>
|
||||
<? endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3>Convention Archives</h3>
|
||||
<p>These URLs lead to the auto-generated convention archive pages for the specified convention.</p>
|
||||
|
||||
<table class="table table-striped table-bordered table-condensed">
|
||||
<colgroup>
|
||||
<col width="40%" />
|
||||
<col width="60%" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Convention Name</th>
|
||||
<th>Convention URL</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<? foreach($this->convention_urls as $record): ?>
|
||||
<tr class="input">
|
||||
<td><?=$record['name'] ?></td>
|
||||
<td><a href="<?=$record['url'] ?>" target="_blank"><?=$record['url'] ?></a></td>
|
||||
</tr>
|
||||
<? endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
Loading…
Reference in New Issue
Block a user