From: Calin Burloiu Date: Wed, 27 Jul 2011 07:52:23 +0000 (+0300) Subject: homepage, categories pages; javascript and stylesheets renamed to js and css resp. X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?p=living-lab-site.git;a=commitdiff_plain;h=a11428ed0b4651895e27d6920c219d8d2476631c homepage, categories pages; javascript and stylesheets renamed to js and css resp. --- diff --git a/.htaccess b/.htaccess index d9fdd6a..25b547b 100644 --- a/.htaccess +++ b/.htaccess @@ -20,5 +20,5 @@ RewriteEngine on -RewriteCond $1 !^(index\.php|img|stylesheets|javascript|data|robots\.txt) +RewriteCond $1 !^(index\.php|img|css|js|data|robots\.txt) RewriteRule ^(.*)$ index.php/$1 [L] diff --git a/application/config/p2p-tube.php b/application/config/p2p-tube.php index b17610a..89bd1ef 100644 --- a/application/config/p2p-tube.php +++ b/application/config/p2p-tube.php @@ -21,12 +21,12 @@ $config['site_name'] = 'P2P-Next UPB LivingLab'; | page generated with 'application/views/html_begin.php' view and | HTML_head_params library. | -| Do not include any path to the file! 'stylesheets/' is going to be used. +| Do not include any path to the file! 'css/' is going to be used. | | Leave blank for no default stylesheet. | */ -$config['default_stylesheet'] = 'default.css'; +$config['default_css'] = 'default.css'; /* |-------------------------------------------------------------------------- @@ -37,12 +37,12 @@ $config['default_stylesheet'] = 'default.css'; | HTML page generated with 'application/views/html_begin.php' view and | HTML_head_params library. | -| Do not include any path to the file! 'javascripts/' is going to be used. +| Do not include any path to the file! 'js/' is going to be used. | | Leave blank for no default javascript. | */ -$config['default_javascript'] = ''; +$config['default_js'] = ''; /* |-------------------------------------------------------------------------- @@ -86,3 +86,23 @@ $config['default_torrent_ext'] = 'tstream'; | */ $config['categories'] = array(1 => 'Movies', 2 => 'TechTalks', 3 => 'Events', 4 => 'Karaoke'); + +/* +|-------------------------------------------------------------------------- +| Videos per page +|-------------------------------------------------------------------------- +| +| The number of video icons shown per page (as in catalog/category). +| +*/ +$config['videos_per_page'] = 16; + +/* +|-------------------------------------------------------------------------- +| Videos per row +|-------------------------------------------------------------------------- +| +| The number of video icons shown on a single line (as in home page). +| +*/ +$config['videos_per_row'] = 4; diff --git a/application/config/pagination.php b/application/config/pagination.php new file mode 100644 index 0000000..8df4933 --- /dev/null +++ b/application/config/pagination.php @@ -0,0 +1,7 @@ +'; +$config['full_tag_close'] = ''; \ No newline at end of file diff --git a/application/controllers/catalog.php b/application/controllers/catalog.php index e6d2c0d..3447167 100644 --- a/application/controllers/catalog.php +++ b/application/controllers/catalog.php @@ -8,15 +8,25 @@ */ class Catalog extends CI_Controller { + public function __construct() + { + parent::__construct(); + } + public function index() { // Retrieve videos summary. + $data['categories'] = $this->config->item('categories'); $this->load->model('videos_model'); - $data['videos'] = $this->videos_model->get_videos_summary(); + foreach ($data['categories'] as $id => $name) + { + $data['videos'][$id] = $this->videos_model->get_videos_summary( + $id, 0, $this->config->item('videos_per_row')); + } $params = array( 'title' => $this->config->item('site_name'), - //'stylesheets' => array(), - //'javascripts' => array(), + 'css' => array('catalog.css'), + //'js' => array(), //'metas' => array('description'=>'','keywords'=>'') ); $this->load->library('html_head_params', $params); @@ -29,25 +39,41 @@ class Catalog extends CI_Controller { $this->load->view('html_end'); } - public function test() + public function test($page = 0) { $this->load->helper('url'); + $this->load->library('pagination'); - echo 'link'; + $config['base_url'] = site_url('catalog/test/'); + $config['total_rows'] = '160'; + $this->pagination->initialize($config); + echo $this->pagination->create_links(); } - public function category($category_id) + public function category($category_id, $offset = 0) { // Retrieve videos summary. $this->load->model('videos_model'); - $data['videos'] = $this->videos_model->get_videos_summary($category_id); + $data['videos'] = $this->videos_model->get_videos_summary( + $category_id, intval($offset), + $this->config->item('videos_per_page')); $categories = $this->config->item('categories'); $data['category'] = $categories[$category_id]; $data['category_id'] = $category_id; + // Pagination + $this->load->library('pagination'); + $pg_config['base_url'] = site_url("catalog/category/$category_id/"); + $pg_config['uri_segment'] = 4; + $pg_config['total_rows'] = $this->videos_model->get_videos_count( + $category_id); + $pg_config['per_page'] = $this->config->item('videos_per_page'); + $this->pagination->initialize($pg_config); + $data['pagination'] = $this->pagination->create_links(); + $params = array( 'title' => $this->config->item('site_name'), - 'stylesheets' => array('catalog.css'), - //'javascripts' => array(), + 'css' => array('catalog.css'), + //'js' => array(), //'metas' => array('description'=>'','keywords'=>'') ); $this->load->library('html_head_params', $params); diff --git a/application/controllers/video.php b/application/controllers/video.php index 64a1e63..f892349 100644 --- a/application/controllers/video.php +++ b/application/controllers/video.php @@ -39,8 +39,8 @@ class Video extends CI_Controller { // Display page. $params = array( 'title' => $data['video']['title'] . ' -- ' . $this->config->item('site_name'), - 'stylesheets' => array('jquery-ui.css', 'NextShare_VLC_plugin.css'), - 'javascripts' => array('jquery.min.js', 'jquery-ui.min.js', 'NextShare_VLC_plugin.js', 'video.js'), + 'css' => array('jquery-ui.css', 'NextShare_VLC_plugin.css'), + 'js' => array('jquery.min.js', 'jquery-ui.min.js', 'NextShare_VLC_plugin.js', 'video.js'), //'metas' => array('description'=>'','keywords'=>'') ); $this->load->library('html_head_params', $params); @@ -56,7 +56,7 @@ class Video extends CI_Controller { /** * AJAX page which retrieves a video plugin. * - * The associated with this controller should be parameter type + * The view associated with this controller should be parameter type * concatenated with '_plugin_view' and must be located in * 'application/views/video'. * diff --git a/application/libraries/Html_head_params.php b/application/libraries/Html_head_params.php index fec1055..6723455 100644 --- a/application/libraries/Html_head_params.php +++ b/application/libraries/Html_head_params.php @@ -12,8 +12,8 @@ * The variables are passed as data in 'application/views/html_begin.php' which * is going to generate the tags based on their information. * - * All .css files must be located in 'stylesheets' and all .js file in - * 'javascripts'. + * All .css files must be located in 'css' and all .js file in + * 'js'. * * @category Library * @author Călin-Andrei Burloiu @@ -21,24 +21,24 @@ class Html_head_params { public $title; // List of .css files - public $stylesheets; + public $css; // List of .js files - public $javascripts; + public $js; // Dictionary for meta tags: name => content public $metas; /** * Initializes member variables with the parameters provided and adds the - * default stylesheet to member $stylesheets and the default script to - * member $javascripts. The URL prefixes are also added to filenames. + * default stylesheet to member $css and the default script to + * member $js. The URL prefixes are also added to filenames. * * Do not add in the parameters list the default stylesheet and script! * * @access public * @param array $params asscociative list with the following parameters: * * 'title' => HTML title tag content (page title) - * * 'stylesheets' => list of .css files without any path - * * 'javascripts' => list of .js files without any path + * * 'css' => list of .css files without any path + * * 'js' => list of .js files without any path * * 'metas' => associative list of "name => content" meta */ public function __construct($params) @@ -52,15 +52,15 @@ class Html_head_params { else $this->title = ''; - if (isset($params['stylesheets'])) - $this->stylesheets = $params['stylesheets']; + if (isset($params['css'])) + $this->css = $params['css']; else - $this->stylesheets = array(); + $this->css = array(); - if (isset($params['javascripts'])) - $this->javascripts = $params['javascripts']; + if (isset($params['js'])) + $this->js = $params['js']; else - $this->javascripts = array(); + $this->js = array(); if (isset($params['metas'])) $this->metas = $params['metas']; @@ -68,16 +68,16 @@ class Html_head_params { $this->metas = array(); // Default parameters from configuration file - if ($CI->config->item('default_stylesheet') != '') - $this->stylesheets[] = $CI->config->item('default_stylesheet'); - if ($CI->config->item('default_javascript') != '') - $this->javascripts[] = $CI->config->item('default_javascript'); + if ($CI->config->item('default_css') != '') + $this->css[] = $CI->config->item('default_css'); + if ($CI->config->item('default_js') != '') + $this->js[] = $CI->config->item('default_js'); // URL correct prefixes - foreach ($this->stylesheets as $i => $val) - $this->stylesheets[$i] = site_url("stylesheets/$val"); - foreach ($this->javascripts as $i => $val) - $this->javascripts[$i] = site_url("javascript/$val"); + foreach ($this->css as $i => $val) + $this->css[$i] = site_url("css/$val"); + foreach ($this->js as $i => $val) + $this->js[$i] = site_url("js/$val"); } } diff --git a/application/models/videos_model.php b/application/models/videos_model.php index 223def7..3ab8592 100644 --- a/application/models/videos_model.php +++ b/application/models/videos_model.php @@ -25,6 +25,9 @@ class Videos_model extends CI_Model { * displayed in the catalog. * * TODO: filter, limit, ordering parameters + * @param int $category_id DB category ID + * @param int $offset + * @param int $count * @return array a list of videos, each one being an assoc array with: * * id, name, title, duration, thumbs_count, default_thumb, views => from DB * * shorted_title => ellipsized title @@ -32,7 +35,7 @@ class Videos_model extends CI_Model { * * TODO: user_id, user_name * * thumbs => thumbnail images' URLs */ - public function get_videos_summary($category_id) + public function get_videos_summary($category_id, $offset, $count) { $this->load->helper('text'); @@ -41,9 +44,14 @@ class Videos_model extends CI_Model { default_thumb FROM `videos` WHERE category_id = ? - ORDER BY name', // TODO summary order - $category_id); - $videos = $query->result_array(); + ORDER BY name + LIMIT ?, ?', // TODO summary order + array(intval($category_id), $offset, $count)); + + if ($query->num_rows() > 0) + $videos = $query->result_array(); + else + return NULL; foreach ($videos as & $video) { @@ -63,6 +71,21 @@ class Videos_model extends CI_Model { return $videos; } + public function get_videos_count($category_id) + { + $query = $this->db->query( + 'SELECT COUNT(*) count + FROM `videos` + WHERE category_id = ?', + $category_id); + + if ($query->num_rows() > 0) + return $row = $query->row()->count; + + // Error + return NULL; + } + /** * Retrieves information about a video. * diff --git a/application/views/catalog/category_view.php b/application/views/catalog/category_view.php index d4e8127..6831bb6 100644 --- a/application/views/catalog/category_view.php +++ b/application/views/catalog/category_view.php @@ -1,19 +1,21 @@
+

-
+ +
- -
@@ -22,6 +24,9 @@
+ + +
diff --git a/application/views/catalog/index_view.php b/application/views/catalog/index_view.php index ef62249..0905dc3 100644 --- a/application/views/catalog/index_view.php +++ b/application/views/catalog/index_view.php @@ -1,15 +1,37 @@
- -
- +
+ + $category_name): ?> +
+

+ "> + + +

+ + +
+ +
-
+ +
-
-
- -
- +
+
+ + +
+
+ +
+ + +
+
+ + +
diff --git a/application/views/html_begin.php b/application/views/html_begin.php index 12490b2..9ccf899 100644 --- a/application/views/html_begin.php +++ b/application/views/html_begin.php @@ -8,11 +8,11 @@ <?php echo $title ?> - + - + diff --git a/application/views/video/watch_view.php b/application/views/video/watch_view.php index 98aac30..dd9f6d6 100644 --- a/application/views/video/watch_view.php +++ b/application/views/video/watch_view.php @@ -1,4 +1,7 @@ - + +
@@ -19,14 +22,14 @@

- + diff --git a/stylesheets/NextShare_VLC_plugin.css b/css/NextShare_VLC_plugin.css similarity index 100% rename from stylesheets/NextShare_VLC_plugin.css rename to css/NextShare_VLC_plugin.css diff --git a/stylesheets/catalog.css b/css/catalog.css similarity index 50% rename from stylesheets/catalog.css rename to css/catalog.css index 3ee4581..eba58b2 100644 --- a/stylesheets/catalog.css +++ b/css/catalog.css @@ -12,30 +12,42 @@ height: 190px; margin-right: 8px; } + .video-icon .video-thumb { position: relative; - width: 128px; - height: 98px; - background: url('/LivingLab/img/thumb_container.png') no-repeat left top; + width: 132px; + height: 99px; + background: url('/devel/img/thumb_container.png') no-repeat left top; } -.video-icon .video-thumb > img +.video-icon .video-thumb img { position: absolute; margin: auto; - left: 4px; + left: 6px; top: 4px; } -.video-icon .video-thumb > .video-duration +.video-icon .video-thumb .video-duration { position: absolute; - right: 5px; + right: 6px; bottom: 5px; font-size: 10px; font-weight: bold; color: white; background: black; } +.video-icon .video-thumb a +{ + border-style: none; + text-decoration: none; +} -Scorpions - Wind of Change / Gloria Gaynor - I Will Survive -Independenta Romaniei: Rasboiul Romano-Ruso-Turc 1877 \ No newline at end of file +.video-icon .video-title +{ + font-size: 12px; +} +.video-icon .video-views +{ + font-size: 12px; +} \ No newline at end of file diff --git a/css/default.css b/css/default.css new file mode 100644 index 0000000..5e8e017 --- /dev/null +++ b/css/default.css @@ -0,0 +1,47 @@ +body +{ + font-family: Arial, Helvetica, sans-serif; + font-size: 13px; + background: white url('/devel/img/bg.png') repeat-x left top; +} + +a:link +{ + color: rgb(0,90,192); + text-decoration: none; +} +a:visited +{ + color: rgb(0,56,112); +} +a:hover, a:active +{ + text-decoration: underline; +} + +#header +{ + clear: both; +} + +#body +{ + position: relative; +} + +#content +{ + float: left; + width: 616px; + padding: 12px; +} + +#footer +{ + clear: both; +} + +.pagination +{ + clear: both; +} diff --git a/stylesheets/jquery-ui.css b/css/jquery-ui.css similarity index 100% rename from stylesheets/jquery-ui.css rename to css/jquery-ui.css diff --git a/img/bg.png b/img/bg.png new file mode 100644 index 0000000..8a64257 Binary files /dev/null and b/img/bg.png differ diff --git a/img/thumb_container.png b/img/thumb_container.png index 0a3a70f..e83a93c 100644 Binary files a/img/thumb_container.png and b/img/thumb_container.png differ diff --git a/img/thumb_container02.png b/img/thumb_container02.png new file mode 100644 index 0000000..3db86b4 Binary files /dev/null and b/img/thumb_container02.png differ diff --git a/javascript/NextShare_VLC_plugin.js b/js/NextShare_VLC_plugin.js similarity index 100% rename from javascript/NextShare_VLC_plugin.js rename to js/NextShare_VLC_plugin.js diff --git a/javascript/default.js b/js/default.js similarity index 100% rename from javascript/default.js rename to js/default.js diff --git a/javascript/jquery-1.6.2.min.js b/js/jquery-1.6.2.min.js similarity index 100% rename from javascript/jquery-1.6.2.min.js rename to js/jquery-1.6.2.min.js diff --git a/javascript/jquery-ui.min.js b/js/jquery-ui.min.js similarity index 100% rename from javascript/jquery-ui.min.js rename to js/jquery-ui.min.js diff --git a/javascript/jquery.js b/js/jquery.js similarity index 100% rename from javascript/jquery.js rename to js/jquery.js diff --git a/javascript/jquery.min.js b/js/jquery.min.js similarity index 100% rename from javascript/jquery.min.js rename to js/jquery.min.js diff --git a/javascript/video.js b/js/video.js similarity index 62% rename from javascript/video.js rename to js/video.js index 284e7ee..2e0f574 100644 --- a/javascript/video.js +++ b/js/video.js @@ -1,7 +1,11 @@ +/** + * Video page client scripting (AJAX, events etc.) + */ + // Usually replaced in PHP siteUrl = '/'; -function getNsVlcPlugin(videoUrl) +function retrieveNsVlcPlugin(videoUrl) { $.post( siteUrl + 'video/plugin/ns-vlc', @@ -12,7 +16,7 @@ function getNsVlcPlugin(videoUrl) ); } -function getNsHtml5Plugin(videoUrl) +function retrieveNsHtml5Plugin(videoUrl) { $.post( siteUrl + 'video/plugin/ns-html5', @@ -21,4 +25,9 @@ function getNsHtml5Plugin(videoUrl) $('#video_plugin').html(data); } ); -} \ No newline at end of file +} + +/*$(document).ready(function() +{ + $ +}*/ \ No newline at end of file diff --git a/stylesheets/default.css b/stylesheets/default.css deleted file mode 100644 index 4ed1cd3..0000000 --- a/stylesheets/default.css +++ /dev/null @@ -1,27 +0,0 @@ -body -{ - font-size: 13px; -} - -#header -{ - clear: both; -} - -#body -{ - position: relative; -} - -#content -{ - float: left; - width: 640px; - padding: 12px; - outline: 1px solid gray; /*TODO*/ -} - -#footer -{ - clear: both; -}