[blam/gtk-builder] ItemView: show author and pubdate



commit a9eefe321a64835ab724c094ef3d94abf8117d50
Author: Carlos Martín Nieto <cmn dwim me>
Date:   Sat Oct 12 17:49:18 2013 +0200

    ItemView: show author and pubdate

 src/ItemView.cs |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/src/ItemView.cs b/src/ItemView.cs
index ff14589..6c8de38 100644
--- a/src/ItemView.cs
+++ b/src/ItemView.cs
@@ -18,6 +18,7 @@ using System.Reflection;
 using System.IO;
 using System.Net;
 using System.Text;
+using System.Linq;
 using System.ComponentModel;
 using System.ServiceModel.Syndication;
 
@@ -58,7 +59,22 @@ namespace Blam
                void UpdateView()
                {
                        var text = current.Summary != null ? current.Summary.Text : null;
-                       text = text ?? (current.Content != null ? (current.Content as 
TextSyndicationContent).Text : null);
+                       text = text ?? (current.Content != null ? (current.Content as 
TextSyndicationContent).Text : String.Empty);
+
+                       string author;
+                       var authors = String.Join(",", current.Authors.Select(a => a.Name).Where(x => x != 
null));
+                       if (authors == String.Empty) {
+                               author = "&nbsp;";
+                       } else {
+                               author = String.Format(Catalog.GetString("by {0}"), authors);
+                       }
+
+                       var date = current.LastUpdatedTime > current.PublishDate ? current.LastUpdatedTime : 
current.PublishDate;
+                       string pubdate;
+                       if (date.Equals(DateTimeOffset.MinValue))
+                               pubdate = Catalog.GetString("[No date available]");
+                       else
+                               pubdate = date.ToString("D", 
System.Globalization.CultureInfo.CurrentUICulture);
 
                        var title   = current.Title.Text;
                        var theme   = ThemeManager.Current;
@@ -67,8 +83,10 @@ namespace Blam
                        var url     = current.Links.Count == 0 ? current.Id : current.Links[0].Uri.ToString();
 
                        var replaces = new Dictionary<string, string> {
+                               {"author", author},
                                {"text", text},
                                {"title", title},
+                               {"pubdate", pubdate},
                                {"link", link},
                                {"url", url},
                                {"localbase", baseDir},


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]