incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [08/36] git commit: [#6829] Make activity timeline look better
Date Mon, 16 Dec 2013 17:09:47 GMT
[#6829] Make activity timeline look better

Along with style changes, this also includes adding a 'summary' key
to the activity_extras dict for several ActivityObject subclasses,
and adding an 'icon_url' key to the User activity_extras dict.

Signed-off-by: Tim Van Steenburgh <tvansteenburgh@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/d20a1de8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/d20a1de8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/d20a1de8

Branch: refs/heads/cj/6821
Commit: d20a1de8573fec99593848dc9648f2d26d12822c
Parents: 633b107
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Wed Dec 4 22:01:58 2013 +0000
Committer: Cory Johns <admin1@users.sf.net>
Committed: Mon Dec 9 15:52:11 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/auth.py                     |  6 ++++
 Allura/allura/model/discuss.py                  | 11 +++++++
 Allura/allura/model/repo.py                     |  2 ++
 ForgeActivity/forgeactivity/main.py             |  1 +
 .../forgeactivity/nf/activity/css/activity.css  | 29 ++++++++++++++++++
 .../forgeactivity/templates/index.html          | 31 ++++++++++++++++----
 ForgeBlog/forgeblog/model/blog.py               |  8 ++++-
 ForgeTracker/forgetracker/model/ticket.py       |  6 ++++
 ForgeWiki/forgewiki/model/wiki.py               |  8 ++++-
 9 files changed, 95 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d20a1de8/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 432898b..d1f5b7f 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -407,6 +407,12 @@ class User(MappedClass, ActivityNode, ActivityObject):
         return self.display_name or self.username
 
     @property
+    def activity_extras(self):
+        d = ActivityObject.activity_extras.fget(self)
+        d.update(icon_url=self.icon_url())
+        return d
+
+    @property
     def stats(self):
         if 'userstats' in g.entry_points['stats']:
             from forgeuserstats.model.stats import UserStats

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d20a1de8/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index 7b4f306..4043c3e 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -18,6 +18,7 @@
 import logging
 from datetime import datetime
 
+import jinja2
 import pymongo
 from pymongo.errors import DuplicateKeyError
 from pylons import tmpl_context as c, app_globals as g
@@ -492,6 +493,16 @@ class Post(Message, VersionedArtifact, ActivityObject):
         return artifact_access and security.has_access(self, perm, user,
                 self.project)
 
+    @property
+    def activity_extras(self):
+        d = ActivityObject.activity_extras.fget(self)
+        summary = jinja2.Markup.escape(
+                g.markdown.cached_convert(self, 'text')).striptags()
+        if len(summary) > 80:
+            summary = summary[:80] + '...'
+        d.update(summary=summary)
+        return d
+
     def index(self):
         result = super(Post, self).index()
         result.update(

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d20a1de8/Allura/allura/model/repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo.py b/Allura/allura/model/repo.py
index 8918b02..d9a4a10 100644
--- a/Allura/allura/model/repo.py
+++ b/Allura/allura/model/repo.py
@@ -186,6 +186,8 @@ class Commit(RepoObject, ActivityObject):
 
     def has_activity_access(self, perm, user, activity):
         """
+        Check access against the original app.
+
         Commits have no ACLs and are therefore always viewable by any user, if
         they have access to the tool.
         """

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d20a1de8/ForgeActivity/forgeactivity/main.py
----------------------------------------------------------------------
diff --git a/ForgeActivity/forgeactivity/main.py b/ForgeActivity/forgeactivity/main.py
index dbdceee..6249ed0 100644
--- a/ForgeActivity/forgeactivity/main.py
+++ b/ForgeActivity/forgeactivity/main.py
@@ -47,6 +47,7 @@ class ForgeActivityApp(Application):
     def __init__(self, project, config):
         Application.__init__(self, project, config)
         self.root = ForgeActivityController()
+        g.register_app_css('css/activity.css', app=self)
 
     def main_menu(self): # pragma no cover
         return []

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d20a1de8/ForgeActivity/forgeactivity/nf/activity/css/activity.css
----------------------------------------------------------------------
diff --git a/ForgeActivity/forgeactivity/nf/activity/css/activity.css b/ForgeActivity/forgeactivity/nf/activity/css/activity.css
new file mode 100644
index 0000000..be36ba0
--- /dev/null
+++ b/ForgeActivity/forgeactivity/nf/activity/css/activity.css
@@ -0,0 +1,29 @@
+.activity {
+  padding: 0 20px 20px 20px;
+}
+.activity ul.timeline {
+  list-style: none;
+  margin: 0;
+}
+.activity ul.timeline li {
+  padding: 20px;
+  border-bottom: 1px solid #eee;
+}
+.activity ul.timeline li article time {
+  font-size: 12px;
+  color: #777;
+}
+.activity ul.timeline li article h1 {
+  padding: 0;
+  font-size: 16px;
+  line-height: 32px;
+}
+.activity ul.timeline li article p {
+  padding: 0;
+  vertical-align: top;
+  font-size: 14px;
+}
+.activity ul.timeline li article p .avatar {
+  display: inline-block;
+  margin: 0 8px 8px 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d20a1de8/ForgeActivity/forgeactivity/templates/index.html
----------------------------------------------------------------------
diff --git a/ForgeActivity/forgeactivity/templates/index.html b/ForgeActivity/forgeactivity/templates/index.html
index 6189688..eadb82a 100644
--- a/ForgeActivity/forgeactivity/templates/index.html
+++ b/ForgeActivity/forgeactivity/templates/index.html
@@ -40,17 +40,38 @@
   <a href="{{o.activity_url}}">{{o.activity_name}}</a>
 {% endmacro %}
 
+{% macro icon(o, size, className) -%}
+  {% if o.activity_extras.get('icon_url') %}
+    <img src="{{ o.activity_extras.get('icon_url') }}"
+         alt="{{ o.activity_name }}"
+         title="{{ o.activity_name }}"
+         class="emboss{% if size %} x{{size}}{% endif %}{% if className %} {{className}}{%
endif %}">
+  {% else %}
+    <b data-icon="{{g.icons['user'].char}}" class="ico emboss {{g.icons['user'].css}}{%
if size %} x{{size}}{% endif %}{% if className %} {{className}}{% endif %}"></b>
+  {% endif %}
+{%- endmacro %}
+
 {% block content %}
-  <div class="grid-23">
+<div class="activity">
   {% if not timeline %}
     No activity to display.
   {% else %}
-    <ul>
+    <ul class="timeline">
         {% for a in timeline %}
-        <li>{{activity_obj(a.actor)}} {{a.verb}} {{activity_obj(a.obj)}} {% if a.target.activity_name
%}on {{activity_obj(a.target)}}{% endif %} {{h.ago(a.published)}}</li>
-        <!-- Score: {{ a.score }} -->
+        <li>
+          <article>
+            <time datetime="{{a.published}}" title="{{a.published}}">{{h.ago(a.published,
show_date_after=None)}}</time>
+            <h1>{{activity_obj(a.actor)}} {{a.verb}} {{activity_obj(a.obj)}} {% if
a.target.activity_name %}on {{activity_obj(a.target)}}{% endif %}</h1>
+            {% if a.obj.activity_extras.get('summary') %}
+            <p>
+              {{ icon(a.actor, 16, 'avatar') }}
+              {{ a.obj.activity_extras.get('summary') }}
+            </p>
+            {% endif %}
+          </article>
+        </li>
         {% endfor %}
     </ul>
   {% endif %}
-  </div>
+</div>
 {% endblock %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d20a1de8/ForgeBlog/forgeblog/model/blog.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/model/blog.py b/ForgeBlog/forgeblog/model/blog.py
index 2d8f0fd..7e34aea 100644
--- a/ForgeBlog/forgeblog/model/blog.py
+++ b/ForgeBlog/forgeblog/model/blog.py
@@ -114,7 +114,13 @@ class BlogPost(M.VersionedArtifact, ActivityObject):
 
     @property
     def activity_name(self):
-        return 'blog post %s' % self.title
+        return 'a blog post'
+
+    @property
+    def activity_extras(self):
+        d = ActivityObject.activity_extras.fget(self)
+        d.update(summary=self.title)
+        return d
 
     def author(self):
         '''The author of the first snapshot of this BlogPost'''

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d20a1de8/ForgeTracker/forgetracker/model/ticket.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index 5605c70..8cde75a 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -600,6 +600,12 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
     def activity_name(self):
         return 'ticket #%s' % self.ticket_num
 
+    @property
+    def activity_extras(self):
+        d = ActivityObject.activity_extras.fget(self)
+        d.update(summary=self.summary)
+        return d
+
     @classmethod
     def new(cls):
         '''Create a new ticket, safely (ensuring a unique ticket_num'''

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d20a1de8/ForgeWiki/forgewiki/model/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/model/wiki.py b/ForgeWiki/forgewiki/model/wiki.py
index a6565d6..11ad589 100644
--- a/ForgeWiki/forgewiki/model/wiki.py
+++ b/ForgeWiki/forgewiki/model/wiki.py
@@ -107,7 +107,13 @@ class Page(VersionedArtifact, ActivityObject):
 
     @property
     def activity_name(self):
-        return 'wiki page %s' % self.title
+        return 'a wiki page'
+
+    @property
+    def activity_extras(self):
+        d = ActivityObject.activity_extras.fget(self)
+        d.update(summary=self.title)
+        return d
 
     def __json__(self):
         return dict(super(Page, self).__json__(),


Mime
View raw message