diff options
author | Michael Francis <edude03@gmail.com> | 2011-07-17 20:38:31 -0400 |
---|---|---|
committer | Michael Francis <edude03@gmail.com> | 2011-07-17 20:38:31 -0400 |
commit | c9994190d2ba584e1eb95b6b47ff586da7b0f29f (patch) | |
tree | ff4d02327f8e988925036f7406c760dfba8791d3 | |
parent | 7be960630a8c0b4dab94245c73453b22db3f305e (diff) | |
parent | 2baaf56e140a06eed8fe0b1d28d744d34a537d49 (diff) | |
download | otakuhub-c9994190d2ba584e1eb95b6b47ff586da7b0f29f.tar.xz |
Merge branch 'master' of git.raylu.net:otakuhub
-rw-r--r-- | controllers/AnimeController.php | 29 | ||||
-rw-r--r-- | controllers/SearchController.php | 18 | ||||
-rw-r--r-- | models/Kdrama.php | 10 | ||||
-rw-r--r-- | models/Manga.php | 34 | ||||
-rw-r--r-- | views/anime/view.html.php | 142 | ||||
-rw-r--r-- | views/elements/animetable.html.php | 6 | ||||
-rw-r--r-- | views/elements/mangatable.html.php | 29 | ||||
-rw-r--r-- | views/layouts/default.html.php | 4 | ||||
-rw-r--r-- | views/search/index.html.php | 30 | ||||
-rw-r--r-- | views/search/kdrama.html.php | 16 | ||||
-rw-r--r-- | views/search/manga.html.php | 16 | ||||
-rw-r--r-- | webroot/css/base.css | 23 | ||||
-rw-r--r-- | webroot/css/search.css | 8 | ||||
-rw-r--r-- | webroot/css/themes/light.css | 22 | ||||
-rw-r--r-- | webroot/css/view.css | 48 | ||||
-rw-r--r-- | webroot/js/functions.js | 18 |
16 files changed, 342 insertions, 111 deletions
diff --git a/controllers/AnimeController.php b/controllers/AnimeController.php index bd29116..3a40cee 100644 --- a/controllers/AnimeController.php +++ b/controllers/AnimeController.php @@ -5,7 +5,7 @@ namespace app\controllers; use app\models\Anime; class AnimeController extends \lithium\action\Controller { - public $publicActions = array('index', 'view'); + public $publicActions = array('index', 'view', 'cast'); public function index() { @@ -16,12 +16,31 @@ class AnimeController extends \lithium\action\Controller { public function view($id = null) { - if (is_numeric($id)) { - return Anime::search($id, null, 'special_id'); + if (is_numeric($id)) + { + $data = Anime::search($id, null, 'special_id'); + $related = $data['anime']->related; + $str = ''; + for ($i = 0; $i < count($related); $i++) + { + if ($i > 0) $str .= ', '; + $ra = Anime::search($related[$i], null, 'special_id'); + $str .= '<a href="' . $related[$i] . '">' . $ra['anime']->title . '</a>'; + } + $data['related'] = $str; + return $data; } - else { + else + { return $this->redirect(array('controller' => 'search','q' => array('search' => $id))); } - + } + + public function cast($id = null) + { + if (is_numeric($id)) + { + return Anime::search($id, null, 'special_id'); + } } } diff --git a/controllers/SearchController.php b/controllers/SearchController.php index abcaabd..efd25f3 100644 --- a/controllers/SearchController.php +++ b/controllers/SearchController.php @@ -25,8 +25,22 @@ class SearchController extends \lithium\action\Controller { public function anime($by = 'title') { - $q = isset($this->request->query['q']) ? '/' . $this->request->query['q'] . '/i' : ''; + $q = isset($this->request->query['q']) ? $this->request->query['q'] : ''; $page = isset($this->request->query['page']) ? $this->request->query['page'] : 1; - return Anime::search($q, $page, 'title'); + return Anime::search("/$q/i", $page, 'title'); + } + + public function manga($by = 'title') + { + $q = isset($this->request->query['q']) ? $this->request->query['q'] : ''; + $page = isset($this->request->query['page']) ? $this->request->query['page'] : 1; + return Manga::search("/$q/i", $page, 'title'); + } + + public function kdrama($by = 'title') + { + $q = isset($this->request->query['q']) ? $this->request->query['q'] : ''; + $page = isset($this->request->query['page']) ? $this->request->query['page'] : 1; + return Kdrama::search("/$q/i", $page, 'title'); } } diff --git a/models/Kdrama.php b/models/Kdrama.php index f1eee22..12c136d 100644 --- a/models/Kdrama.php +++ b/models/Kdrama.php @@ -13,7 +13,7 @@ class Kdrama extends \lithium\data\Model { switch($by) { case 'special_id': - $content = parent::find('first', + $kdrama = parent::find('first', array('conditions' => array( $by => $query ), @@ -21,13 +21,11 @@ class Kdrama extends \lithium\data\Model { 'page' => $page )); - - $total = parent::count(array($by => $query)); break; default: - $content = parent::find('all', + $kdrama = parent::find('all', array('conditions' => array( $by => array('like' => $query) ), @@ -36,6 +34,6 @@ class Kdrama extends \lithium\data\Model { )); $total = parent::count(array($by => array('like' => $query))); } - return compact('content', 'by', 'limit', 'total', 'page'); + return compact('kdrama', 'by', 'limit', 'total', 'page'); } -}
\ No newline at end of file +} diff --git a/models/Manga.php b/models/Manga.php index 03c2d29..5f79bef 100644 --- a/models/Manga.php +++ b/models/Manga.php @@ -5,5 +5,35 @@ namespace app\models; class Manga extends \lithium\data\Model { protected $_meta = array('key' => '_id', 'source' => 'manga', 'connection' => 'mongo'); - -}
\ No newline at end of file + public static function search($query, $page = 1, $by = 'title') + { + $defaults = array('limit' => 20); + $limit = 20; + + switch($by) { + case 'special_id': + + $manga = parent::find('first', + array('conditions' => array( + $by => $query + ), + 'limit' => $limit, + 'page' => $page + )); + + $total = parent::count(array($by => $query)); + break; + + default: + $manga = parent::find('all', + array('conditions' => array( + $by => array('like' => $query) + ), + 'limit' => $limit, + 'page' => $page + )); + $total = parent::count(array($by => array('like' => $query))); + } + return compact('manga', 'by', 'limit', 'total', 'page'); + } +} diff --git a/views/anime/view.html.php b/views/anime/view.html.php index 4a3b8c9..a722935 100644 --- a/views/anime/view.html.php +++ b/views/anime/view.html.php @@ -1,68 +1,98 @@ -<h2 class="ribbon full"><?= $content->title ?></h2> +<?php +$this->styles($this->html->style('view')); +?> + +<h2 class="ribbon full"><?= $anime->title ?></h2> <div class="triangle-ribbon"></div> -<br class="cl" /> +<br class="cl"> -<div class="container_12"> -<!-- Start Sidebar --> -<div class="grid_4" id="sidebar"> -<img src="<?=$content->image ?>" > +<aside id="img"> +<img src="<?=$anime->image ?>" alt="<?= $anime->title ?>"> +</aside> -<h2 class="ribbon"> Alternative Titles </h2> -<hr/> -<p> -<?php if(isset($content->alternative_titles)) : ?> -<?php foreach($content->alternative_titles as $title): ?> - <?= $title ?> -<?php endforeach; ?> +<section id="info"><p> +<?php if(isset($anime->foreign_titles)): + $str = 'Foreign titles:'; + for ($i = 0; $i < count($anime->foreign_titles); $i++) { + if ($i > 0) $str .= '<b>,</b>'; + $str .= ' ' . $anime->foreign_titles[$i]; + } + $str .= '<br>'; + ?> + <?= $str ?> +<?php endif; ?> +<?php if(isset($anime->alternative_titles)): + $str = 'Alternative titles:'; + for ($i = 0; $i < count($anime->alternative_titles); $i++) { + if ($i > 0) $str .= '<b>,</b>'; + $str .= ' ' . $anime->alternative_titles[$i]; + } + $str .= '<br>'; + ?> + <?= $str ?> <?php endif; ?> +Type: <?= $anime->view_type ?><br> +Episodes: <?= $anime->episode_count ?><br> +Aired: <?= $anime->aired ?><br> +Producers: <?php +$str = ''; +for ($i = 0; $i < count($anime->producers); $i++) { + if ($i > 0) $str .= ','; + $str .= ' <a href="/producer/view/' . $anime->producers[$i] . '">' . $anime->producers[$i] . '</a>'; +} ?><?= $str ?><br> +Genres: <?php +$str = ''; +for ($i = 0; $i < count($anime->genres); $i++) { + if ($i > 0) $str .= ','; + $str .= ' <a href="/genre/view/' . $anime->genres[$i] . '">' . $anime->genres[$i] . '</a>'; +} ?><?= $str ?><br> +Duration: <?= $anime->episode_duration ?><br> +Rating: <?= $anime->rated ?><br> +Related: <?= $related ?> </p> -<h2> Information </h2> -<span> Type: <?= $content->view_type ?> </span> -Episodes: <?= $content->episode_count ?><br/> -Status: <?= $content->status ?><br/> -Aired: <?= $content->aired ?><br/> -Producers: <?php foreach($content->producers as $producer): ?> -<a href="/producer/view/<?= $producer ?>"><?= $producer ?></a>, -<?php endforeach; ?><br/> -Genres: <?php foreach($content->genres as $genres): ?> -<a href="/genres/view/<?= $genres ?>"><?= $genres ?></a>, -<?php endforeach ?><br/> -Duration: <?= $content->episode_duration ?><br/> -Rating: <?= $content->rating ?><br/> +</section> -<h2 class="ribbon">Statistics</h2> -Score: <br/> -Ranked: <br/> -Popularity: <br/> -Members:<br/> -Favorited by: over 9000 Users<br/> - -<h2 class="ribbon"> My Info </h2> -<hr/> -<!-- End Sidebar --> -</div> -<div class="grid_8" id="content"> -<!-- Start Content --> -<h2>Synopsis</h2> -<hr/> -<?= $content->synopsis ?> - -<h2>Related Animes</h2> -<hr/> +<aside id="malstats"> +<h2>MAL Stats</h2> +<p> +Score: <?= $anime->mal_score ?><br> +Votes: <?= $anime->mal_score_voted ?><br> +Ranked: <?= $anime->mal_rank ?><br> +Popularity: <?= $anime->mal_popularity ?><br> +Members: <?= $anime->mal_score ?> +</p> +</aside> -<h2>Characters And VA's </h2> -<hr/> -<?php foreach($content->cast as $char): ?> -<?= $char->character ?> -<?= $char->role ?> -Played by: +<section id="cast"> +<p> +<a href="/anime/cast/<?= $anime->special_id ?>" onclick="return toggleCast()">Cast ↓</a> +</p> +<p><table> +<?php foreach($anime->cast as $char): ?> + <tr> + <td colspan="3"> + <?= $char->character ?> + </td> + </tr> <?php if (isset($char->people)): ?> <?php foreach($char->people as $actor): ?> - <?= $actor->name ?> - <?= $actor->language ?> + <tr> + <td></td> + <td><?= $actor->name ?></td> + <td><?= $actor->language ?></td> + </tr> <?php endforeach; ?> <?php endif; ?> <?php endforeach; ?> -</div> -<br class="cl"/> -</div>
\ No newline at end of file +</table></p> +<p id="castlink"> +<a href="" onclick="return toggleCast()">Cast ↑</a> +</p> +</section> + +<br class="cl"> + +<h2 class="ribbon">Synopsis</h2> +<div class="triangle-ribbon"></div> +<br class="cl"> +<p><?= $anime->synopsis ?></p> diff --git a/views/elements/animetable.html.php b/views/elements/animetable.html.php index 0d9f9fb..ea222a6 100644 --- a/views/elements/animetable.html.php +++ b/views/elements/animetable.html.php @@ -6,12 +6,12 @@ <tr> <td> <a href="/anime/view/<?= $a->special_id ?>"><?= $a->title ?></a> - <?php if ($a->foreign_titles || $a->alternative_titles): ?> + <?php if (isset($a->foreign_titles) || isset($a->alternative_titles)): ?> <span class="alt_titles"> - <?php if ($a->foreign_titles): ?> + <?php if (isset($a->foreign_titles)): ?> <?= $a->foreign_titles[0] ?> <?php endif ?> - <?php if ($a->alternative_titles): ?> + <?php if (isset($a->alternative_titles)): ?> <?= $a->alternative_titles[0] ?> <?php endif ?> diff --git a/views/elements/mangatable.html.php b/views/elements/mangatable.html.php new file mode 100644 index 0000000..c92ff83 --- /dev/null +++ b/views/elements/mangatable.html.php @@ -0,0 +1,29 @@ +<table> +<th>Title</th> +<th>Date</th> +<th style="width: 200px">Type</th> +<?php foreach ($manga as $m): ?> + <tr> + <td> + <a href="/manga/view/<?= $m->special_id ?>"><?= $m->title ?></a> + <?php if (isset($m->foreign_titles) || isset($m->alternative_titles)): ?> + <span class="alt_titles"> + <?php if (isset($m->foreign_titles)): ?> + <?= $m->foreign_titles[0] ?> + <?php endif ?> + <?php if (isset($m->alternative_titles)): ?> + + <?= $m->alternative_titles[0] ?> + <?php endif ?> + </span> + <?php endif ?> + </td> + <td> + <?= $m->publish_period ?> + </td> + <td> + <?= $m->author ?> + </td> + </tr> +<?php endforeach ?> +</table> diff --git a/views/layouts/default.html.php b/views/layouts/default.html.php index 9464d80..9313414 100644 --- a/views/layouts/default.html.php +++ b/views/layouts/default.html.php @@ -69,9 +69,9 @@ use \lithium\security\Auth; <br class="cl" /> </header> -<div id="page"> +<article> <?php echo $this->content() ?> -</div> +</article> <footer> <p>Copyright ©2011, <a href="http://www.melenion.org">Melenion Dev Studios</a></p> <br class="cl" /> diff --git a/views/search/index.html.php b/views/search/index.html.php index bee0bb8..1672570 100644 --- a/views/search/index.html.php +++ b/views/search/index.html.php @@ -5,27 +5,29 @@ $this->styles($this->html->style('search')); <?= $this->_render('element', 'search') ?> +<?php if(count($anime) > 0): ?> <h2 class="ribbon">Anime</h2> <div class="triangle-ribbon"></div> -<?= $this->_render('element', 'animetable', compact('anime')) ?> -<p class="more"> -<a href="/search/anime/?q=<?= $q ?>">More</a> -</p> + <?= $this->_render('element', 'animetable') ?> + <p class="more"> + <a href="/search/anime/?q=<?= $q ?>">More</a> + </p> +<?php endif ?> +<?php if(count($manga) > 0): ?> <h2 class="ribbon">Manga</h2> <div class="triangle-ribbon"></div> -<p>results</p> -<?php if(count($manga) > 0): ?> -<p class="more"> -<a href="/search/manga/?q=<?= $q ?>">More</a> -</p> + <?= $this->_render('element', 'mangatable') ?> + <p class="more"> + <a href="/search/manga/?q=<?= $q ?>">More</a> + </p> <?php endif ?> +<?php if(count($kdrama) > 0): ?> <h2 class="ribbon">K-Drama</h2> <div class="triangle-ribbon"></div> -<?= $this->_render('element', 'kdramatable', compact('anime')) ?> -<?php if(count($kdrama) > 0): ?> -<p class="more"> -<a href="/search/kdrama/?q=<?= $q ?>">More</a> -</p> + <?= $this->_render('element', 'kdramatable') ?> + <p class="more"> + <a href="/search/kdrama/?q=<?= $q ?>">More</a> + </p> <?php endif ?> diff --git a/views/search/kdrama.html.php b/views/search/kdrama.html.php new file mode 100644 index 0000000..8736902 --- /dev/null +++ b/views/search/kdrama.html.php @@ -0,0 +1,16 @@ +<?php +$this->styles($this->html->style('pagination')); +$this->styles($this->html->style('table')); +$this->styles($this->html->style('search')); +?> + +<?= $this->_render('element', 'search') ?> + +<h2>K-Drama Search Results</h2> +(search instead for ...) + +<?= $this->Paginator->paginate(array('separator' => '')) ?> + +<?= $this->_render('element', 'kdramatable') ?> + +<?= $this->Paginator->paginate(array('separator' => '')) ?> diff --git a/views/search/manga.html.php b/views/search/manga.html.php new file mode 100644 index 0000000..181994b --- /dev/null +++ b/views/search/manga.html.php @@ -0,0 +1,16 @@ +<?php +$this->styles($this->html->style('pagination')); +$this->styles($this->html->style('table')); +$this->styles($this->html->style('search')); +?> + +<?= $this->_render('element', 'search') ?> + +<h2>Manga Search Results</h2> +(search instead for ...) + +<?= $this->Paginator->paginate(array('separator' => '')) ?> + +<?= $this->_render('element', 'mangatable') ?> + +<?= $this->Paginator->paginate(array('separator' => '')) ?> diff --git a/webroot/css/base.css b/webroot/css/base.css index 29fd2c3..1bbd83c 100644 --- a/webroot/css/base.css +++ b/webroot/css/base.css @@ -24,6 +24,8 @@ h2.ribbon { border-radius: 3px 3px 3px 0px; -moz-border-radius: 3px 3px 3px 0px; -webkit-border-radius: 3px 3px 3px 0px; +} +h2.full { width: 890px; } .triangle-ribbon { @@ -146,11 +148,11 @@ footer { width: 980px; margin: 25px auto 20px; } -#page { +article { background: #fff; color: #191919; border: 1px solid #d9d9d9; - padding: 40px; + padding: 25px 40px 30px; position: relative; width: 898px; margin: 0 auto; @@ -243,13 +245,16 @@ body.ie7 form, body.ie8 { form p { margin-bottom:15px; } -form input, form textarea { +form input, form textarea, form select { padding: 7px 5px; border: 1px solid #ccc; border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; } +form select { + padding: 6px 5px; +} input[type="button"], input[type="submit"], button { padding: 6px 5px; /* looks high in FF at inherited 7 5 */ line-height: 18px; /* looks small in webkit at 6 5 */ @@ -257,24 +262,12 @@ input[type="button"], input[type="submit"], button { display: inline-block; font-weight: 700; outline: none; - background: #ddd; color: #444; text-shadow: 0 -1px 0 #eee; border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; } -input[type="button"]:hover, input[type="submit"]:hover, button:hover { - background: #eee; -} -form select { - padding: 6px 5px; - border: 1px solid #ccc; - border-radius: 3px; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - background-color: #eee; -} div#login { text-align: center; diff --git a/webroot/css/search.css b/webroot/css/search.css index ff9907e..20ea164 100644 --- a/webroot/css/search.css +++ b/webroot/css/search.css @@ -16,13 +16,13 @@ p.more a { border-radius: 3px; background: #ddd; background: -moz-linear-gradient(top, #ddd, #bbb); - background: -webkit-linear-gradient(top, rgba(255,255,255,1), rgba(255,255,255,0)); - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffffff00', GradientType=1); + background: -webkit-linear-gradient(top, #ddd, #bbb); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#dddddd', endColorstr='#bbbbbb'); color: #111; } p.more a:hover { background: #eee; background: -moz-linear-gradient(top, #eee, #ccc); - background: -webkit-linear-gradient(top, rgba(255,255,255,1), rgba(255,255,255,0)); - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffffff00', GradientType=1); + background: -webkit-linear-gradient(top, #eee, #ccc); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#cccccc'); } diff --git a/webroot/css/themes/light.css b/webroot/css/themes/light.css index b3b95ae..677557a 100644 --- a/webroot/css/themes/light.css +++ b/webroot/css/themes/light.css @@ -48,6 +48,28 @@ a.gradient:hover { color: #fff; } +form input, form textarea, form select { + background: #f7f7f7; + background: -moz-linear-gradient(top, #eee, #fff); + background: -webkit-linear-gradient(top, #eee, #fff); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eee', endColorstr='#fff'); +} +input[type="button"], input[type="submit"], button { + background: #ddd; + background: -moz-linear-gradient(top, #ddd, #eee); + background: -webkit-linear-gradient(top, #ddd, #eee); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ddd', endColorstr='#eee'); +} +form input:focus, form textarea:focus, select:focus { + border-color: #88c; +} +input[type="button"]:hover, input[type="submit"]:hover, button:hover { + background: #eee; + background: -moz-linear-gradient(top, #e0e0e0, #f7f7f7); + background: -webkit-linear-gradient(top, #e0e0e0, #f7f7f7); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#e0e0e0', endColorstr='#f7f7f7'); +} + footer { color: #666; } diff --git a/webroot/css/view.css b/webroot/css/view.css new file mode 100644 index 0000000..4b0a9a1 --- /dev/null +++ b/webroot/css/view.css @@ -0,0 +1,48 @@ +/* for viewing individual anime/manga/kdrama, rather than table.css */ + +aside#img { + float: left; + margin: 0 25px 25px 0; + width: 225px; +} + +section#info { + float: left; + width: 470px; +} + +section#cast { + float: left; + width: 620px; +} +section#cast p { + margin: 0; +} +section#cast table { + table-layout: fixed; + display: none; +} +section#cast td { + padding: 3px; +} +section#cast td:nth-child(1) { + width: 60px; +} +section#cast td:nth-child(2) { + width: 250px; +} +section#cast td:nth-child(3) { + width: 200px; +} +section#cast #castlink { + display: none; +} + +aside#malstats { + float: right; + width: 150px; +} + +p { + text-indent: 0; +} diff --git a/webroot/js/functions.js b/webroot/js/functions.js index 510b0cf..86f3f3c 100644 --- a/webroot/js/functions.js +++ b/webroot/js/functions.js @@ -10,8 +10,22 @@ jQuery(document).ready(function($) { $('form [title]').tipsy({fade: true, trigger: 'focus', gravity: 'w'}); setTimeout(function() { - $(".flash-message").fadeOut("slow", function () { - $(".flash-message").remove(); + $('.flash-message').fadeOut('slow', function () { + $('.flash-message').remove(); }); }, 2000); }); + +function toggleCast() { + var table = $('#cast table'); + if (table.css('display') == 'inline') { + table.css('display', 'none'); + $('#cast > p > a').text('Cast ↓'); + $('#castlink').css('display', 'none'); + } else { + table.css('display', 'inline'); + $('#cast > p > a').text('Cast ↑'); + $('#castlink').css('display', 'inline'); + } + return false; +} |