--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/candolint/adapters.py Tue Jul 05 20:48:01 2016 +0800
+class HostingAdapter(object):
+ def __init__(self, project):
+ def get_commit_url(self, change):
+ def get_branch_url(self, change):
+class BitbucketAdapter(HostingAdapter):
+ def get_commit_url(self, change):
+ return '{url}/commits/{node}'.format(**{
+ 'url': self.project.url,
+ def get_branch_url(self, change):
+ return '{url}/branch/{branch}'.format(**{
+ 'url': self.project.url,
+ 'branch': change.branch
--- a/candolint/handlers.py Tue Jul 05 20:44:04 2016 +0800
+++ b/candolint/handlers.py Tue Jul 05 20:48:01 2016 +0800
def get_html(self, project, check, lines):
- self.render('check.html', project=project, check=check, lines=lines)
+ adapter = project.get_adapter()
+ self.render('check.html', project=project, check=check, lines=lines, adapter=adapter)
class StatusHandler(BaseHandler):
--- a/candolint/models.py Tue Jul 05 20:44:04 2016 +0800
+++ b/candolint/models.py Tue Jul 05 20:48:01 2016 +0800
+from __future__ import absolute_import
+from candolint import adapters
database = pw.SqliteDatabase(None, journal_mode='WAL')
owner = self.user if self.user is not None else self.domain
return '{}/{}'.format(owner, self.name)
+ if self.domain == 'bitbucket.org':
+ return adapters.BitbucketAdapter(self)
+ return adapters.HostingAdapter(self)
--- a/templates/check.html Tue Jul 05 20:44:04 2016 +0800
+++ b/templates/check.html Tue Jul 05 20:48:01 2016 +0800
<dl class="uk-description-list-horizontal list-terse">
{% set change = check.change %}
- <dd>{{ change.rev }}:{{ change.node[:12] }}</dd>
+ <dd><a href="{{ adapter.get_commit_url(change) }}">{{ change.rev }}:{{ change.node[:12] }}</a></dd>
- <dd>{{ change.branch }}</dd>
+ <dd><a href="{{ adapter.get_branch_url(change) }}">{{ change.branch }}</a></dd>
<dd>{{ change.author }}</dd>
--- a/templates/index.html Tue Jul 05 20:44:04 2016 +0800
+++ b/templates/index.html Tue Jul 05 20:48:01 2016 +0800
{% for check in checks %}
{% set project = check.project %}
{% set change = check.change %}
+ {% set adapter = project.get_adapter() %}
<td>{% module Badges(check) %}</td>
<td><a href="{{ check.get_url() }}">check #{{ check.ordinal }}</a></td>
<td class="uk-width-1-1 uk-text-break"><a href="{{ project.get_url() }}">{{ project.get_title() }}</a></td>
- <td>{{ change.branch }}</td>
- <td>{{ change.rev }}:{{ change.node[:12] }}</td>
+ <td><a href="{{ adapter.get_branch_url(change) }}">{{ change.branch }}</a></td>
+ <td><a href="{{ adapter.get_commit_url(change) }}">{{ change.rev }}:{{ change.node[:12] }}</a></td>
<td>{% module Time(check.finished) %}</td>
<td>{{ check.get_duration() }}</td>
--- a/templates/project.html Tue Jul 05 20:44:04 2016 +0800
+++ b/templates/project.html Tue Jul 05 20:48:01 2016 +0800
{% for check in checks %}
{% set change = check.change %}
+ {% set adapter = project.get_adapter() %}
<td>{% module Badges(check) %}</td>
<td><a href="{{ check.get_url() }}">check #{{ check.ordinal }}</a></td>
- <td>{{ change.branch }}</td>
- <td>{{ change.rev }}:{{ change.node[:12] }}</td>
+ <td><a href="{{ adapter.get_branch_url(change) }}">{{ change.branch }}</a></td>
+ <td><a href="{{ adapter.get_commit_url(change) }}">{{ change.rev }}:{{ change.node[:12] }}</a></td>
<td class="uk-width-1-1 uk-text-break">
<div>{{ change.message }}</div>
<div>{{ change.author }}, {% module Time(change.date, False) %}</div>