</Files>
RewriteEngine on
-RewriteCond $1 !^(index\.php|images|stylesheets|javascript|data|robots\.txt)
+RewriteCond $1 !^(index\.php|img|stylesheets|javascript|data|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
*/
$config['default_torrent_ext'] = 'tstream';
+/*
+|--------------------------------------------------------------------------
+| Categories
+|--------------------------------------------------------------------------
+|
+| An associative list with the video categories of the site. IDs are used
+| in DB (for example in `videos` table), and value are human-friendly names
+| for categories. IDs must be numeric and must preferably start from 1.
+|
+*/
+$config['categories'] = array(1 => 'Movies', 2 => 'TechTalks', 3 => 'Events', 4 => 'Karaoke');
$route['default_controller'] = "catalog";
$route['404_override'] = '';
+$route['watch/([\d]+)/?'] = "video/watch/$1";
+$route['watch/([\d]+)/(.+)'] = "video/watch/$1/$2";
+
/* End of file routes.php */
/* Location: ./application/config/routes.php */
\ No newline at end of file
echo '<a href="/">link</a>';
}
+ public function category($category_id)
+ {
+ // Retrieve videos summary.
+ $this->load->model('videos_model');
+ $data['videos'] = $this->videos_model->get_videos_summary($category_id);
+ $categories = $this->config->item('categories');
+ $data['category'] = $categories[$category_id];
+ $data['category_id'] = $category_id;
+
+ $params = array( 'title' => $this->config->item('site_name'),
+ 'stylesheets' => array('catalog.css'),
+ //'javascripts' => array(),
+ //'metas' => array('description'=>'','keywords'=>'')
+ );
+ $this->load->library('html_head_params', $params);
+ $this->load->view('html_begin', $this->html_head_params);
+ $this->load->view('header');
+
+ $this->load->view('catalog/category_view', $data);
+
+ $this->load->view('footer');
+ $this->load->view('html_end');
+ }
+
public function search($query_str)
{
echo $query_str;
{
$this->load->library('singleton_db');
$this->db = $this->singleton_db->connect();
-
- $this->load->helper('url');
}
+
+ $this->load->helper('url');
}
/**
* TODO: filter, limit, ordering parameters
* @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
* * video_url => P2P-Tube video URl
* * TODO: user_id, user_name
* * thumbs => thumbnail images' URLs
*/
- public function get_videos_summary()
+ public function get_videos_summary($category_id)
{
+ $this->load->helper('text');
+
$query = $this->db->query(
'SELECT id, name, title, duration, user_id, views, thumbs_count,
default_thumb
FROM `videos`
- ORDER BY name'); // TODO summary order
+ WHERE category_id = ?
+ ORDER BY name', // TODO summary order
+ $category_id);
$videos = $query->result_array();
foreach ($videos as & $video)
{
// P2P-Tube Video URL
- $video['video_url'] = site_url(sprintf("video/watch/%d/%s",
+ $video['video_url'] = site_url(sprintf("watch/%d/%s",
$video['id'], $video['name']));
// Thumbnails
$video['thumbs'] = $this->get_thumbs($video['name'],
$video['thumbs_count']);
+
+ // Ellipsized title
+ //$video['shorted_title'] = ellipsize($video['title'], 45, 0.75);
+ $video['shorted_title'] = character_limiter($video['title'], 45);
}
return $videos;
--- /dev/null
+<div id="body">
+<div id="content">
+
+<h1><?php echo $category ?></h1>
+
+<div class="video-list">
+<?php foreach($videos as $video):
+ $thumb_src = $video['thumbs'][ $video['default_thumb'] ];
+ ?>
+ <div class="video-icon">
+ <a href="<?php echo $video['video_url'] ?>">
+ <div class="video-thumb">
+ <img src="<?php echo $thumb_src ?>" />
+ <div class="video-duration"><?php echo $video['duration'] ?></div>
+ </div>
+ </a>
+ <div class="video-title">
+ <a href="<?php echo $video['video_url'] ?>">
+ <?php echo $video['shorted_title'] ?></a>
+ </div>
+ <div class="video-views"><?php echo $video['views'] . ' views' ?></div>
+ <!--<div class="video-username"><?php echo 'TODO: print user name' ?></div>-->
+ </div>
+<?php endforeach ?>
+</div>
+
+</div>
+</div>
<div id="video_description"><?php echo $video['description'] ?></div>
<!-- TODO <div id="video_category">Category: <?php echo $video['category_name'] ?></div>-->
<div id="video_tags">Tags:
- <?php foreach($video['tags'] as $tag => $score): ?>
+ <?php print_r($video['tags']) ?>
+ <?php if (isset($video['tags'])):
+ foreach ($video['tags'] as $tag => $score): ?>
<a href="<?php site_url('catalog/search/'. $tag) ?>">
<?php echo "$tag($score)" ?>
</a>
- <?php endforeach ?>
+ <?php endforeach; endif ?>
<div id="video_license"><?php echo $video['license'] ?></div>
# Copyright Calin-Andrei Burloiu, calin.burloiu@gmail.com
#
# Automatically publishes videos in P2P-Tube DB based on the video files and
-# a videos info file. Parameters: videos_info_file videos_directory category
+# a videos info file. Parameters: videos_info_file videos_directory category_id
#
import sys
import MySQLdb
directory = os.curdir
default_video_ext = 'ogv'
- def __init__(self, dbCur, directory, name, title, description, tags, category):
+ def __init__(self, dbCur, directory, name, title, description, tags, category_id):
self.dbCur = dbCur
self.directory = directory
self.description = description
self.duration, self.formats = self.findVideosMeta()
self.formats_json = json.dumps(self.formats, separators=(',', ':'))
- self.category = category
+ self.category_id = category_id
tagList = tags.split(',')
self.tags = {}
for tag in tagList:
- self.tags[tag.strip()] = 0
+ if tag != '':
+ self.tags[tag.strip()] = 0
self.tags_json = json.dumps(self.tags, separators=(',', ':'))
def getVideoDefinition(self, fileName):
def insert(self):
if self.duration == None or self.formats_json == None or self.tags_json == None:
print "Bzzzz"
- query = "INSERT INTO `" + self.tableName + "` (name, title, description, duration, formats, category, user_id, tags, date, thumbs_count, default_thumb) VALUES ('" + self.name + "', '" + self.title + "', '" + self.description + "', '" + self.duration + "', '" + self.formats_json + "', '" + self.category + "', " + str(self.user_id) + ", '" + self.tags_json + "', NOW(), " + str(self.thumbs_count) + ", " + str(self.default_thumb) + ")"
+ query = "INSERT INTO `" + self.tableName + "` (name, title, description, duration, formats, category_id, user_id, tags, date, thumbs_count, default_thumb) VALUES ('" + self.name + "', '" + self.title + "', '" + self.description + "', '" + self.duration + "', '" + self.formats_json + "', " + str(self.category_id) + ", " + str(self.user_id) + ", '" + self.tags_json + "', NOW(), " + str(self.thumbs_count) + ", " + str(self.default_thumb) + ")"
self.dbCur.execute(query)
@staticmethod
- def getAllNames(dbCur, category):
+ def getAllNames(dbCur, category_id):
allNames = set()
- query = "SELECT name FROM `" + VideosTable.tableName + "` WHERE category = '" + category + "'"
+ query = "SELECT name FROM `" + VideosTable.tableName + "` WHERE category_id = " + str(category_id)
dbCur.execute(query)
while(True):
def main():
# Check arguments.
if len(sys.argv) < 3:
- sys.stdout.write('usage: ' + sys.argv[0] + ' videos_info_file videos_dir category\n')
+ sys.stdout.write('usage: ' + sys.argv[0] + ' videos_info_file videos_dir category_id\n')
exit(1)
# Command line arguments
fileName = sys.argv[1]
directory = sys.argv[2]
- category = sys.argv[3]
+ category_id = int(sys.argv[3])
if len(sys.argv) == 4:
thumbsDir = sys.argv[3]
else:
passwd = 'ahmitairoo', db = 'koala_livinglab')
dbCur = dbConn.cursor()
- allNames = VideosTable.getAllNames(dbCur, category)
+ allNames = VideosTable.getAllNames(dbCur, category_id)
# Open info file
file = open(fileName, 'r')
if not name in allNames:
sys.stdout.write(str(i) + '. ' + name + '\r')
try:
- video = VideosTable(dbCur, directory, name, title, description, tags, category)
+ video = VideosTable(dbCur, directory, name, title, description, tags, category_id)
video.insert()
i = i+1
# Clean-up
dbCur.close()
dbConn.close()
+ sys.stdout.write('\n')
return 0
--- /dev/null
+.video-list
+{
+ position: relative;
+}
+
+.video-icon
+{
+ position: relative;
+ display: block;
+ float: left;
+ width: 146px;
+ 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;
+}
+.video-icon .video-thumb > img
+{
+ position: absolute;
+ margin: auto;
+ left: 4px;
+ top: 4px;
+}
+.video-icon .video-thumb > .video-duration
+{
+ position: absolute;
+ right: 5px;
+ bottom: 5px;
+ font-size: 10px;
+ font-weight: bold;
+ color: white;
+ background: black;
+}
+
+Scorpions - Wind of Change / Gloria Gaynor - I Will Survive
+Independenta Romaniei: Rasboiul Romano-Ruso-Turc 1877
\ No newline at end of file
--- /dev/null
+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;
+}