Преглед изворни кода

Implémentation des vues lecture et globale (issue #67)

Marien Fressinaud пре 13 година
родитељ
комит
36316a6d7e

+ 3 - 3
app/models/Category.php

@@ -35,10 +35,10 @@ class Category extends Model {
 	public function feeds () {
 		if (is_null ($this->feeds)) {
 			$feedDAO = new FeedDAO ();
-			return $feedDAO->listByCategory ($this->id ());
-		} else {
-			return $this->feeds;
+			$this->feeds = $feedDAO->listByCategory ($this->id ());
 		}
+
+		return $this->feeds;
 	}
 
 	public function _id ($value) {

+ 30 - 2
app/views/helpers/global_view.phtml

@@ -1,5 +1,33 @@
+<?php $this->partial ('nav_menu'); ?>
+
+<div id="stream" class="global">
 <?php
-$this->partial ('nav_menu');
+	foreach ($this->cat_aside as $cat) {
+		$feeds = $cat->feeds ();
+		$catNotRead = $cat->nbNotRead ();
+		if (!empty ($feeds)) {
 ?>
+	<div class="category">
+		<div class="cat_header"><a href="<?php echo _url ('index', 'index', 'get', 'c_' . $cat->id ()); ?>"><?php echo $cat->name(); ?><?php echo $catNotRead > 0 ? ' (' . $catNotRead . ')' : ''; ?></a></div>
+
+		<ul class="feeds">
+			<?php foreach ($feeds as $feed) { ?>
+			<?php $not_read = $feed->nbNotRead (); ?>
+			<li class="item">
+				<img class="favicon" src="<?php echo $feed->favicon (); ?>" alt="" />
 
-Non implémenté
+				<a href="<?php echo _url ('index', 'index', 'get', 'f_' . $feed->id ()); ?>">
+				<?php echo $not_read > 0 ? '<b>' : ''; ?>
+				<?php echo $feed->name(); ?>
+				<?php echo $not_read > 0 ? ' (' . $not_read . ')' : ''; ?>
+				<?php echo $not_read > 0 ? '</b>' : ''; ?>
+				</a>
+			</li>
+			<?php } ?>
+		</ul>
+	</div>
+<?php
+		}
+	}
+?>
+</div>

+ 1 - 1
app/views/helpers/normal_view.phtml

@@ -7,7 +7,7 @@ if (isset ($this->entryPaginator) && !$this->entryPaginator->isEmpty ()) {
 	$items = $this->entryPaginator->items ();
 ?>
 
-<div id="stream">
+<div id="stream" class="normal">
 	<?php
 		$display_today = true;
 		$display_yesterday = true;

+ 1 - 0
app/views/helpers/reader_view.phtml

@@ -1,4 +1,5 @@
 <?php
+$this->partial ('nav_menu');
 
 if (isset ($this->entryPaginator) && !$this->entryPaginator->isEmpty ()) {
 	$items = $this->entryPaginator->items ();

+ 18 - 1
app/views/javascript/main.phtml

@@ -9,6 +9,16 @@ var hide_posts = false;
 	$mark = $this->conf->markWhen ();
 ?>
 
+function is_reader_mode() {
+	var stream = $("#stream.reader");
+	return stream.html() != null;
+}
+
+function is_normal_mode() {
+	var stream = $("#stream.normal");
+	return stream.html() != null;
+}
+
 function redirect (url, new_tab) {
 	if (url) {
 		if (new_tab) {
@@ -117,7 +127,7 @@ function init_posts () {
 	<?php } ?>
 
 	if (hide_posts) {
-		$("#stream:not(.reader) .flux:not(.active) .flux_content").hide ();
+		$(".flux:not(.active) .flux_content").hide ();
 	}
 
 	$(".flux_header .item.title, .flux_header .item.date").click (function () {
@@ -153,6 +163,10 @@ function init_posts () {
 }
 
 function init_column_categories () {
+	if(!is_normal_mode()) {
+		return;
+	}
+
 	$(".category").addClass ("stick");
 	$(".categories .category .btn:first-child").width ("160px");
 	$(".category").append ("<a class=\"btn dropdown-toggle\" href=\"#\"><i class=\"icon i_down\"></i></a>");
@@ -268,6 +282,9 @@ function init_shortcuts () {
 }
 
 $(document).ready (function () {
+	if(is_reader_mode()) {
+		hide_posts = false;
+	}
 	init_posts ();
 	init_column_categories ();
 	init_shortcuts ();

+ 38 - 0
public/theme/freshrss.css

@@ -298,6 +298,44 @@
 		color: #666;
 	}
 
+#stream.global {
+	text-align: center;
+}
+	#stream.global .category {
+		display: inline-block;
+		width: 280px;
+		margin: 20px 10px;
+		vertical-align: top;
+		background: #fff;
+		border: 1px solid #aaa;
+		border-radius: 5px;
+		text-align: left;
+		box-shadow: 0 0 5px #bbb;
+	}
+		#stream.global .cat_header {
+			height: 35px;
+			padding: 0 10px;
+			background: #eee;
+			border-bottom: 1px solid #aaa;
+			border-radius: 5px 5px 0 0;
+			line-height: 35px;
+			font-size: 120%;
+		}
+			#stream.global .cat_header a {
+				color: #333;
+				text-shadow: 0 -1px 0px #aaa;
+			}
+		#stream.global .category .feeds {
+			max-height: 250px;
+			margin: 0;
+			list-style: none;
+			overflow: auto;
+		}
+			#stream.global .category .feeds .item {
+				padding: 0 10px;
+				font-size: 90%;
+			}
+
 .content {
 	max-width: 550px;
 	margin: 0 auto;