#150 Add a position to each widget and some code clean up
Merged 7 years ago by pingou. Opened 7 years ago by pingou.
pingou/fedora-hubs widget_position  into  develop

file modified
+5 -2
@@ -11,8 +11,10 @@ 

  

  

  def markup(text):

-     return markdown.markdown(text, safe_mode="replace",

-                              html_replacement_text="--RAW HTML NOT ALLOWED--")

+     return markdown.markdown(

+         text,

+         safe_mode="replace",

+         html_replacement_text="--RAW HTML NOT ALLOWED--")

  

  

  def username2avatar(username, s=312):
@@ -29,6 +31,7 @@ 

  def commas(numeric):

      return "{:,}".format(numeric)

  

+ 

  def github_repos(token, username):

      log.info("Finding github repos for %r" % username)

      tmpl = "https://api.github.com/users/{username}/repos?per_page=100"

file modified
+7
@@ -6,29 +6,36 @@ 

  def required(session, value):

      return bool(value)

  

+ 

  def text(session, value):

      return kitchen.text.converters.to_unicode(value)

  

+ 

  def integer(session, value):

      return int(value)

  

+ 

  def link(session, value):

      # TODO -- verify that this is actually a link

      return value

  

+ 

  def username(session, value):

      openid = 'http://%s.id.fedoraproject.org/' % value

      return not hubs.models.User.by_openid(session, openid) is None

  

+ 

  def github_organization(session, value):

      # TODO -- implement this.

      return True

  

+ 

  def fmn_context(session, value):

      # TODO get this from the fedmsg config.

      return value in [

          'irc', 'email', 'android', 'desktop', 'hubs',

      ]

  

+ 

  def pagure_repo(session, value):

      return value

@@ -57,6 +57,13 @@ 

          if not callable(module.template.render):

              raise TypeError('%r\'s template.render not callable' % module)

  

+         if not hasattr(module, 'position'):

+             raise AttributeError('%r has not "position" function' % module)

+         if module.position not in ['left', 'right', 'both']:

+             raise TypeError(

+                 '%r\'s "position" is not: `left`, `right` or `both`'

+                 % module)

+ 

          if not hasattr(module, 'data'):

              raise AttributeError('%r has not "data" function' % module)

          if not callable(module.data):

file modified
+1 -1
@@ -8,7 +8,7 @@ 

  

  chrome = panel("<span class='glyphicon glyphicon-info-sign' aria-hidden='true'></span> About")

  template = templating.environment.get_template('templates/about.html')

- 

+ position = 'both'

  

  @argument(name="text", default="I am a Fedora user, and this is my about",

            validator=validators.text,

file modified
+1 -1
@@ -11,7 +11,7 @@ 

  from hubs.widgets.chrome import panel

  chrome = panel("Badges")

  template = templating.environment.get_template('templates/badges.html')

- 

+ position = 'right'

  

  @argument(name="username",

            default=None,

file modified
+1 -1
@@ -9,7 +9,7 @@ 

  

  chrome = panel("Bugzilla: Issues")

  template = templating.environment.get_template('templates/bugzilla.html')

- 

+ position = 'right'

  

  @argument(name="username",

            default=None,

file modified
+1
@@ -7,6 +7,7 @@ 

  

  chrome = panel("This is a dummy widget")

  template = templating.environment.get_template('templates/dummy.html')

+ position = 'both'

  

  @argument(name="text", default="Lorem ipsum dolor...",

            validator=validators.text,

@@ -14,6 +14,7 @@ 

  

  chrome = panel()

  template = templating.environment.get_template('templates/fedmsgstats.html')

+ position = 'both'

  

  

  def data(session, widget, username):

file modified
+1 -1
@@ -38,7 +38,7 @@ 

  #from hubs.widgets.chrome import panel

  #chrome = panel()

  template = templating.environment.get_template('templates/feed.html')

- 

+ position = 'left'

  

  def apply_markup(match):

      markup = match['subtitle']

@@ -15,6 +15,7 @@ 

  

  chrome = panel("Github: Pull Requests")

  template = templating.environment.get_template('templates/github_pr.html')

+ position = 'right'

  

  

  @argument(name="display_number",

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

  

  chrome = panel("Github: Newest Open Tickets")

  template = templating.environment.get_template('templates/githubissues.html')

+ position = 'right'

  

  

  @argument(name="repo",

@@ -10,6 +10,7 @@ 

  from hubs.widgets.chrome import panel

  chrome = panel("Weekly Activity")

  template = templating.environment.get_template('templates/linechart.html')

+ position = 'left'

  

  

  @argument(name="username",

@@ -55,6 +55,7 @@ 

  chrome = panel(title = 'Reminders', key='meetings', footer_template=footer_template)

  templating.environment.filters['humanize'] = lambda d: arrow.get(d).humanize()

  template = templating.environment.get_template('templates/meetings.html')

+ position = 'both'

  

  

  @argument(name="calendar",

@@ -11,6 +11,7 @@ 

  

  chrome = panel("Newest Open Pull Requests on Pagure")

  template = templating.environment.get_template('templates/pagure_pr.html')

+ position = 'right'

  

  

  @argument(name="repo",

@@ -9,6 +9,7 @@ 

  

  chrome = panel("Newest Open Tickets on Pagure")

  template = templating.environment.get_template('templates/pagureissues.html')

+ position = 'right'

  

  

  @argument(name="repo",

file modified
+1
@@ -8,6 +8,7 @@ 

  

  chrome = panel()

  template = templating.environment.get_template('templates/rules.html')

+ position = 'both'

  

  

  @argument(name='link', default=None,

file modified
+1
@@ -8,6 +8,7 @@ 

  

  chrome = panel()

  template = templating.environment.get_template('templates/stats.html')

+ position = 'right'

  

  

  def data(session, widget):

file modified
+1
@@ -7,6 +7,7 @@ 

  

  chrome = panel(title='Sticky Note', klass="card-info")

  template = templating.environment.get_template('templates/sticky.html')

+ position = 'both'

  

  

  @argument(name="text", default="Lorem ipsum dolor...",

@@ -16,6 +16,7 @@ 

  

  chrome = panel('Hubs', key='associations')

  template = templating.environment.get_template('templates/subscriptions.html')

+ position = 'right'

  

  

  @argument(name="username",

@@ -12,6 +12,7 @@ 

  chrome = panel('Pending ACL Requests', key='pending_acls')

  # TODO -- add approve/deny buttons or just link through to pkgdb

  template = templating.environment.get_template('templates/workflow/pendingacls.html')

+ position = 'right'

  

  

  @argument(name="username",

@@ -12,6 +12,7 @@ 

  # TODO -- add approve/deny buttons or just link through to pkgdb

  template = templating.environment.get_template(

      'templates/workflow/updates2stable.html')

+ position = 'right'

  

  # TODO - the bodhi api exposes a new flag we can use instead of scraping comments...

  giveaway = 'can be pushed to stable now'