#112 Allow feed entries to expand/collapse if they are conglomerates.
Merged 8 years ago by ralph. Opened 8 years ago by ralph.

@@ -0,0 +1,12 @@ 

+ // These two functions are used by the feed widget to expand and collapse

+ // entries.

+ var expand_feed_entries = function(idx) {

+     $("#expand-" + idx).addClass('hidden');

+     $("#collapse-" + idx).removeClass('hidden');

+     $("#content-" + idx).removeClass('hidden');

+ }

+ var collapse_feed_entries = function(idx) {

+     $("#expand-" + idx).removeClass('hidden');

+     $("#collapse-" + idx).addClass('hidden');

+     $("#content-" + idx).addClass('hidden');

+ }

@@ -143,6 +143,7 @@ 

  

  <script src="{{ url_for('static', filename='js/jquery-1.10.2.min.js') }}"></script>

  <script src="{{ url_for('static', filename='bootstrap/js/bootstrap.min.js') }}"></script>

+ <script src="{{ url_for('static', filename='js/utils.js') }}"></script>

  <script>

  var widgets = [{% for widget in hub.widgets %}'{{ widget.idx }}',{% endfor %}];

  $.each(widgets, function(i, widget) {

file modified
+49 -20
@@ -43,6 +43,30 @@ 

        <div class="media-body">

          <h4 class="media-heading">{{match['markup']}}</h4>

          {{match['human_time']}}

+         {% if match['msg_ids'] | length > 1 %}

+             <div class="pull-right">

+                 <a id="expand-{{match['dom_id']}}" href="javascript:expand_feed_entries('{{match['dom_id']}}');">

+                     <span class="glyphicon glyphicon-chevron-down"></span>

+                     expand

+                 </a>

+                 <a id="collapse-{{match['dom_id']}}" href="javascript:collapse_feed_entries('{{match['dom_id']}}');" class="hidden">

+                     <span class="glyphicon glyphicon-chevron-up"></span>

+                     collapse

+                 </a>

+             </div>

+             <ul id="content-{{match['dom_id']}}" class="hidden list-unstyled">

+                 {% for idx, constituent in match['msg_ids'].items() %}

+                 <li>

+                     {{ constituent['markup'] }}

+                     {% if constituent['link'] %}

+                     <a href="{{constituent['link']}}" target="_blank">

+                         <span class="glyphicon glyphicon-new-window"></span>

+                     </a>

+                     {% endif %}

+                 </li>

+                 {% endfor %}

+             </ul>

+         {% endif %}

        </div>

      </div>

    </div>
@@ -54,6 +78,28 @@ 

  #from hubs.widgets.chrome import panel

  #chrome = panel()

  

+ def apply_markup(match):

+     markup = match['subtitle']

+     for username in match['usernames']:

+         args = (username, '<a href="{url}">@{username}</a>'.format(

+             url=flask.url_for('hub', name=username),

+             username=username,

+         ))

+         markup = markup.replace(*args)

+         # TODO -- have to add these to conglomerate first

+         #match['long_form'] = match['long_form'].replace(*args)

+ 

+     for package in match['packages']:

+         args = (package, '<a href="{url}">{package}</a>'.format(

+             url='https://apps.fedoraproject.org/packages/' + package,

+             package=package,

+         ))

+         markup = markup.replace(*args)

+         # TODO -- have to add these to conglomerate first

+         #match['long_form'] = match['long_form'].replace(*args)

+ 

+     return markup

+ 

  

  @argument(name="username",

            default=None,
@@ -67,7 +113,6 @@ 

      openid = '%s.id.fedoraproject.org' % username

      url = '/'.join([fmn_url, 'api', openid, fmn_context])

      log.info("Getting FMN preferences from %s" % url)

-     print(url)

      response = requests.get(url)

      messages = []

      matches = []
@@ -113,25 +158,9 @@ 

  

      # Apply some html markup to the subtitles for extra fanciness.

      for match in matches:

-         match['markup'] = match['subtitle']

-         for username in match['usernames']:

-             args = (username, '<a href="{url}">@{username}</a>'.format(

-                 url=flask.url_for('hub', name=username),

-                 username=username,

-             ))

-             match['markup'] = match['markup'].replace(*args)

-             # TODO -- have to add these to conglomerate first

-             #match['long_form'] = match['long_form'].replace(*args)

- 

-         for package in match['packages']:

-             args = (package, '<a href="{url}">{package}</a>'.format(

-                 url='https://apps.fedoraproject.org/packages/' + package,

-                 package=package,

-             ))

-             match['markup'] = match['markup'].replace(*args)

-             # TODO -- have to add these to conglomerate first

-             #match['long_form'] = match['long_form'].replace(*args)

- 

+         match['markup'] = apply_markup(match)

+         for idx, constituent in match['msg_ids'].items():

+             constituent['markup'] = apply_markup(constituent)

  

      return dict(

          matches=matches,

no initial comment

Pull-Request has been updated

8 years ago

Pull-Request has been updated

8 years ago

Pull-Request has been updated

8 years ago

Pull-Request has been merged by ralph

8 years ago