summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorraylu <raylu@mixpanel.com>2011-07-10 23:32:14 -0700
committerraylu <raylu@mixpanel.com>2011-07-10 23:33:03 -0700
commit2e6016922cfeaf32e69f65df8178d71387782e2c (patch)
tree45222803c2b386ed39af4530c9eddc7090f4a60b
parent913bca163e3c00c2f956b7882945b73a5d47ce71 (diff)
downloadotakuhub-2e6016922cfeaf32e69f65df8178d71387782e2c.tar.xz
/anime works
-rw-r--r--controllers/AnimeController.php10
-rw-r--r--models/Anime.php30
-rw-r--r--views/anime/index.html.php40
-rw-r--r--webroot/css/anime.css39
-rw-r--r--webroot/css/base.css3
-rw-r--r--webroot/css/themes/light.css8
6 files changed, 117 insertions, 13 deletions
diff --git a/controllers/AnimeController.php b/controllers/AnimeController.php
index 2fc35cc..3e0c51d 100644
--- a/controllers/AnimeController.php
+++ b/controllers/AnimeController.php
@@ -5,7 +5,13 @@ namespace app\controllers;
use app\models\Anime;
class AnimeController extends \lithium\action\Controller {
- public $publicActions = array('view');
+ public $publicActions = array('index', 'view');
+
+ public function index()
+ {
+ $page = $this->request->query['page'];
+ return Anime::search(null, $page, null);
+ }
public function view($id = null)
{
@@ -17,4 +23,4 @@ class AnimeController extends \lithium\action\Controller {
}
}
-} \ No newline at end of file
+}
diff --git a/models/Anime.php b/models/Anime.php
index 4543826..8281ea7 100644
--- a/models/Anime.php
+++ b/models/Anime.php
@@ -11,8 +11,7 @@ class Anime extends \lithium\data\Model {
$limit = 20;
switch($by) {
- case 'special_id':
-
+ case 'special_id':
$content = self::find('first',
array('conditions' => array(
$by => $query
@@ -22,20 +21,29 @@ class Anime extends \lithium\data\Model {
));
-
$total = self::count(array($by => $query));
break;
- default:
- $content = self::find('all',
- array('conditions' => array(
- $by => array('like' => $query)
- ),
+ default:
+ if ($query)
+ {
+ $conditions = null; // TODO
+ $content = self::find('all', array(
+ 'conditions' => array($by => array('like' => $query)),
'limit' => $limit,
'page' => $page
));
$total = Anime::count(array($by => array('like' => $query)));
+ }
+ else
+ {
+ $content = self::find('all', array(
+ 'limit' => $limit,
+ 'page' => $page
+ ));
+ $total = Anime::count();
+ }
+ }
+ return compact('content', 'by', 'limit', 'total', 'page');
}
- return compact('content', 'by', 'limit', 'total', 'page');
- }
-} \ No newline at end of file
+}
diff --git a/views/anime/index.html.php b/views/anime/index.html.php
new file mode 100644
index 0000000..a67fd5e
--- /dev/null
+++ b/views/anime/index.html.php
@@ -0,0 +1,40 @@
+<?php
+$this->styles($this->html->style('anime'));
+?>
+
+<h2 class="ribbon full">Anime</h2>
+<div class="triangle-ribbon"></div>
+
+<?= $this->Paginator->paginate(array('separator' => '')) ?>
+
+<table>
+<th>Title</th>
+<th>Date</th>
+<th>Type</th>
+<?php foreach ($content as $anime): ?>
+ <tr>
+ <td>
+ <a href="/anime/view/<?= $anime->special_id ?>"><?= $anime->title ?></a>
+ <?php if ($anime->foreign_titles || $anime->alternative_titles): ?>
+ <span class="alt_titles">
+ <?php if ($anime->foreign_titles): ?>
+ <?= $anime->foreign_titles[0] ?>
+ <?php endif ?>
+ <?php if ($anime->alternative_titles): ?>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+ <?= $anime->alternative_titles[0] ?>
+ <?php endif ?>
+ </span>
+ <?php endif ?>
+ </td>
+ <td>
+ <?= $anime->aired ?>
+ </td>
+ <td>
+ <?= $anime->view_type ?>
+ </td>
+ </tr>
+<?php endforeach ?>
+</table>
+
+<?= $this->Paginator->paginate(array('separator' => '')) ?>
diff --git a/webroot/css/anime.css b/webroot/css/anime.css
new file mode 100644
index 0000000..03f0883
--- /dev/null
+++ b/webroot/css/anime.css
@@ -0,0 +1,39 @@
+span.alt_titles {
+ font-size: 90%;
+ opacity: 0.7;
+}
+
+table {
+ border-collapse: collapse;
+ width: 898px;
+ max-width: 898px;
+ table-layout: fixed;
+}
+tr {
+ height: 45px;
+}
+tr:first-child { /* th row */
+ height: 25px;
+}
+th {
+ vertical-align: middle;
+}
+th:nth-child(2) {
+ width: 240px;
+}
+th:nth-child(3) {
+ width: 50px;
+}
+td {
+ border: 0px solid #bbb;
+ border-top-width: 1px;
+ vertical-align: middle;
+ white-space: nowrap;
+ overflow: hidden;
+}
+td:nth-child(2) {
+ padding-left: 25px;
+}
+td a {
+ display: block;
+}
diff --git a/webroot/css/base.css b/webroot/css/base.css
index ab9cca3..e783306 100644
--- a/webroot/css/base.css
+++ b/webroot/css/base.css
@@ -2,6 +2,9 @@ body {
font-family: Cantarell;
letter-spacing: -0.01em;
}
+a:link, a:visited {
+ text-decoration: none;
+}
h1 {
font-weight: bold;
font-size: 220%;
diff --git a/webroot/css/themes/light.css b/webroot/css/themes/light.css
index 4ade9ff..c837667 100644
--- a/webroot/css/themes/light.css
+++ b/webroot/css/themes/light.css
@@ -5,6 +5,14 @@ body {
background: -webkit-linear-gradient(top, #fff, #ddd 500px, #ddd);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#dddddd');
}
+
+a, a:visited {
+ color: #33a;
+}
+a:hover {
+ color: #55f;
+}
+
nav a, nav a:visited {
color: #222;
text-shadow:0 1px 0 #fff;