Commits

joberschweiber  committed eb1340c

Revamp journal:

  • Participants
  • Parent commits 0752285

Comments (0)

Files changed (4)

File rhodecode/controllers/journal.py

 
 log = logging.getLogger(__name__)
 
+def action_name(action):
+    simple = {
+        'started_following_repo': _('is following'),
+        'stopped_following_repo': _('is no longer following'),
+        'admin_created_repo': _('created'),
+        'admin_updated_repo': _('updated'),
+        'push_remote': _('pushed remote'),
+        'pull': _('pulled')
+    }
+    if action in simple:
+        return simple[action]
+    elif action.startswith('push:'):
+        return _('pushed into')
+    elif action.startswith('user_forked_repo:'):
+        return _('forked')
+    else:
+        log.warn('I don\'t know action %s' % action)
 
 class JournalController(BaseController):
 
         journal = self._get_journal_data(c.following)
 
         c.journal_pager = Page(journal, page=p, items_per_page=20)
-
-        c.journal_day_aggreagate = self._get_daily_aggregate(c.journal_pager)
+        c.action_name = action_name
 
         c.journal_data = render('journal/journal_data.html')
         if request.environ.get('HTTP_X_PARTIAL_XHR'):
             return c.journal_data
         return render('journal/journal.html')
 
-    def _get_daily_aggregate(self, journal):
-        groups = []
-        for k, g in groupby(journal, lambda x: x.action_as_day):
-            user_group = []
-            for k2, g2 in groupby(list(g), lambda x: x.user.email):
-                l = list(g2)
-                user_group.append((l[0].user, l))
-
-            groups.append((k, user_group,))
-
-        return groups
-
     def _get_journal_data(self, following_repos):
         repo_ids = [x.follows_repository.repo_id for x in following_repos
                     if x.follows_repository is not None]

File rhodecode/public/css/style.css

     margin-bottom: 0;
 }
 
+#journal #entries {
+    margin-top: 20px;
+}
+
 #journal .entry {
     margin-bottom: 20px;
 }
 
-#journal .entry .day {
-    font-size: 1.2em;
-    font-weight: bold;
+#journal .entry .icon {
+    float: left;
+    width: 30px;
 }
 
-#journal .user img {
-    vertical-align: middle;
+#journal .entry .data {
+    font-weight: bold;
+    border-bottom: 1px solid #ccc;
+    width: 550px;
+    margin-left: 30px;
+    padding-bottom: 20px;
 }
 
-#journal .user {
-    font-weight: bold;
+#journal .entry .action {
+    font-style: italic;
 }
 
-#journal .day-entry {
-    margin-top: 10px;
+#journal .entry .details {
+    margin-top: 5px;
+    color: #666;
+    font-weight: normal;
 }
 
-#journal .acts {
-    border-left: 1px solid #bbb;
-    margin-left: 10px;
-}
-
-#journal .action {
-    margin-top: 10px;
-}
-
-#journal .action .primary {
-    margin-left: 10px;
-}
-
-#journal .action .date {
-    margin-left: 10px;
-}
-
-#journal .action .params {
-    margin-left: 15px;
+#journal .entry .details a {
 }
 
 .issue-controls a {

File rhodecode/templates/journal/journal.html

         });
         }
         </script>
-        <div id="journal" class="span8">
+        <div id="journal" class="span10">
                 <h2>${_('Journal')}</h2>
+                <div id="entries">
                 ${c.journal_data}
+                </div>
         </div>
 
-        <div class="span8">
+        <div class="span6">
                 <h2>${_('Following')}</h2>
             <div>
                 %if c.following:

File rhodecode/templates/journal/journal_data.html

 ## -*- coding: utf-8 -*-
 
-%if c.journal_day_aggreagate:
-    %for day,items in c.journal_day_aggreagate:
-    <div class="entry">
-        <div class="day">${day}</div>
-        % for user,entries in items:
-        <div class="day-entry">
-                <div class="user">
-                <img alt="gravatar" src="${h.gravatar_url(user.email,24)}"/>
-                    <span>${user.name} ${user.lastname}</span>
-                </div>
-                <div class="acts">
-            % for entry in entries:
-            <div class="action">
-                    <div class="primary">
-                        ${h.action_parser_icon(entry)} ${h.action_parser(entry)[0]}
-                        %if entry.repository is not None:
-                          ${h.link_to(entry.repository.repo_name,
-                                      h.url('files_home',repo_name=entry.repository.repo_name))}
-                        %else:
-                          ${entry.repository_name}
-                        %endif
-                    </div>
-                    <div class="params">${h.literal(h.action_parser(entry)[1]())}</div>
-                    <div class="date">${h.age(entry.action_date)}</div>
-                </div>
-            %endfor
-            </div>
-        </div>
-        %endfor
+<%def name="repo_link(item)">
+${h.link_to(item.repository.repo_name, h.url('files_home', repo_name=item.repository.repo_name))}
+</%def>
+
+<%def name="boilerplate(item)">
+  <div class="entry">
+    ${self.icon(item)}
+    <div class="data">
+    ${item.user.name} ${item.user.lastname}
+</%def>
+
+<%def name="icon(item)">
+    <div class="icon">${h.action_parser_icon(item)}</div>
+</%def>
+
+%for item in c.journal_pager:
+  %if item.action == 'started_following_repo':
+    ${self.boilerplate(item)}
+    <span class="action">${_('started following')}</span> ${self.repo_link(item)} ${h.age(item.action_date)}
     </div>
+    </div>
+  %elif item.action == 'stopped_following_repo':
+    ${self.boilerplate(item)}
+    <span class="action">${_('stopped following')}</span> ${self.repo_link(item)} ${h.age(item.action_date)}
+    </div>
+    </div>
+  %elif item.action.startswith('push:'):
+    ${self.boilerplate(item)}
+    <span class="action">${_('pushed to')}</span> ${self.repo_link(item)} ${h.age(item.action_date)}
+    <div class="details">
+    %for rev in item.action.split(':')[1].split(','):
+      <a href="${h.url('changeset_home', repo_name=item.repository.repo_name, revision=rev)}">${rev}</a>  ${item.repository.get_changeset(rev).message} <br />
     %endfor
+    </div>
+    </div>
+    </div>
+  %elif item.action == 'admin_created_repo':
+    ${self.boilerplate(item)}
+    <span class="action">${_('created')}</span> ${self.repo_link(item)} ${h.age(item.action_date)}
+    </div>
+    </div>
+  %elif item.action == 'admin_updated_repo':
+    ${self.boilerplate(item)}
+    <span class="action">${_('updated repository')}</span> ${self.repo_link(item)} ${h.age(item.action_date)}
+    </div>
+    </div>
+  %elif item.action.startswith('user_forked_repo'):
+    ${self.boilerplate(item)}
+    <span class="action">${_('forked')}</span> ${self.repo_link(item)} ${_('into')}
+    ${h.link_to(item.action.split(':')[1], h.url('files_home', repo_name=item.action.split(':')[1]))}
+    ${h.age(item.action_date)}
+    </div>
+    </div>
+  %endif
+%endfor
+
 
 <div class="pagination">
 <script type="text/javascript">
 </script>
 ${c.journal_pager.pager('$link_previous ~2~ $link_next')}
 </div>
-%else:
-    ${_('No entries yet')}
-%endif