summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMáirín Duffy <duffy@redhat.com>2011-12-08 21:19:20 (GMT)
committerMáirín Duffy <duffy@redhat.com>2011-12-08 21:19:20 (GMT)
commit5f42caa188774cc7f622844adec79cc0cbffeda1 (patch)
tree413b21dc5a973eb7d118ad6696b4cb815a24a84e
parent6716f4c1e4cf3fd34092daa8557ec2b85ac3b6d3 (diff)
parent9152284c8242e137b8d3f3576b8cb2c93218bf3f (diff)
downloadfedoracommunity-5f42caa188774cc7f622844adec79cc0cbffeda1.zip
fedoracommunity-5f42caa188774cc7f622844adec79cc0cbffeda1.tar.gz
fedoracommunity-5f42caa188774cc7f622844adec79cc0cbffeda1.tar.xz
Merge branch 'fedora-packages' of ssh://git.fedorahosted.org/git/fedoracommunity into fedora-packages
-rw-r--r--MANIFEST.in3
-rw-r--r--development.ini3
-rw-r--r--fedoracommunity.spec2
-rw-r--r--fedoracommunity/config/app_cfg.py24
-rw-r--r--fedoracommunity/config/middleware.py2
-rw-r--r--fedoracommunity/connectors/__init__.py1
-rw-r--r--fedoracommunity/connectors/gitconnector.py142
-rw-r--r--fedoracommunity/ctl/ctl.py1
-rw-r--r--fedoracommunity/distutils/__init__.py0
-rw-r--r--fedoracommunity/distutils/command.py13
-rw-r--r--fedoracommunity/widgets/package/bugs.py4
-rw-r--r--fedoracommunity/widgets/package/builds.py4
-rw-r--r--fedoracommunity/widgets/package/changelog.py4
-rw-r--r--fedoracommunity/widgets/package/contents.py2
-rw-r--r--fedoracommunity/widgets/package/overview.py4
-rw-r--r--fedoracommunity/widgets/package/relationships.py18
-rw-r--r--fedoracommunity/widgets/package/sources.py173
-rw-r--r--fedoracommunity/widgets/package/templates/contents.mak2
-rw-r--r--fedoracommunity/widgets/package/templates/package_spec.mak22
-rw-r--r--fedoracommunity/widgets/package/templates/release_filter.mak6
-rw-r--r--fedoracommunity/widgets/package/templates/tarballs.mak7
-rw-r--r--fedoracommunity/widgets/package/updates.py4
-rw-r--r--fedoracommunity/widgets/widgets.py20
-rw-r--r--orbited.cfg7
-rwxr-xr-xsetup.py4
25 files changed, 322 insertions, 150 deletions
diff --git a/MANIFEST.in b/MANIFEST.in
index 632d180..193135b 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,7 +1,7 @@
recursive-include production *
recursive-include fedoracommunity *.mak
recursive-include fedoracommunity *.js
-recursive-include fedoracommunity/mokshaapps/demos/js/ *.js
+recursive-include fedoracommunity/public/css *.css *.ttf *.png *.gif *.svg *.eot *.woff
include fedoracommunity_makeyumcache
include fedoracommunity.spec
@@ -9,3 +9,4 @@ include orbited.cfg
include README.txt
include AUTHORS
include COPYING
+include build.ini
diff --git a/development.ini b/development.ini
index 5c560a5..ab25230 100644
--- a/development.ini
+++ b/development.ini
@@ -54,7 +54,6 @@ stats_cache = sqlite:///%(here)s/stats.db
# Git settings
git_repo_path = %(here)s/git.fedoraproject.org
-
[server:main]
use = egg:Paste#http
host = 0.0.0.0
@@ -63,6 +62,8 @@ port = 8080
[app:main]
use = egg:fedoracommunity
+#fedoracommunity.resource_path_prefix = /packages
+
# Logging configuration
# Add additional loggers, handlers, formatters here
# Uses python's logging config file format
diff --git a/fedoracommunity.spec b/fedoracommunity.spec
index 7be1924..d964421 100644
--- a/fedoracommunity.spec
+++ b/fedoracommunity.spec
@@ -58,7 +58,7 @@ Fedora Community is a set of web applications for consolidating Fedora Infrastru
%{__rm} -rf %{buildroot}
%{__python} setup.py install -O1 --skip-build \
--install-data=%{_datadir} --root %{buildroot}
-%{__python} setup.py archive_tw2_resources -f -o %{buildroot}%{_datadir}/%{name}/public/toscawidgets -d moksha -d fedoracommunity
+%{__python} setup.py archive_fedoracommunity_resources -f -o %{buildroot}%{_datadir}/%{name}/public/toscawidgets -d moksha -d fedoracommunity
%{__mkdir_p} %{buildroot}/var/lib/
%{__mkdir_p} %{buildroot}%{_datadir}/%{name}/production/apache
diff --git a/fedoracommunity/config/app_cfg.py b/fedoracommunity/config/app_cfg.py
index 63f8755..3fcf176 100644
--- a/fedoracommunity/config/app_cfg.py
+++ b/fedoracommunity/config/app_cfg.py
@@ -19,8 +19,25 @@ import fedoracommunity
import fedoracommunity.lib
from tg.configuration import AppConfig, Bunch
+from paste.deploy.converters import asbool
+from pylons.i18n import ugettext
+
+class FedoraCommunityConfig(AppConfig):
+
+ def add_tosca2_middleware(self, app):
+ from tg import config
+ from tw2.core.middleware import Config, TwMiddleware
+ default_tw2_config = dict( default_engine=self.default_renderer,
+ translator=ugettext,
+ auto_reload_templates=asbool(self.get('templating.mako.reloadfromdisk', 'false'))
+ )
+ res_prefix = config.get('fedoracommunity.resource_path_prefix')
+ if res_prefix:
+ default_tw2_config['res_prefix'] = res_prefix
+ default_tw2_config.update(self.custom_tw2_config)
+ app = TwMiddleware(app, **default_tw2_config)
+ return app
-#class FedoraCommunityConfig(AppConfig):
# def add_auth_middleware(self, app, *args):
# """ Add our FAS authentication middleware """
# from fedoracommunity.connectors.faswhoplugin import fas_make_who_middleware
@@ -41,9 +58,10 @@ from tg.configuration import AppConfig, Bunch
#
# app = fas_make_who_middleware(app, **auth_args)
# return app
-#base_config = FedoraCommunityConfig()
-base_config = AppConfig()
+
+base_config = FedoraCommunityConfig()
+#base_config = AppConfig()
base_config.renderers = []
base_config.use_dotted_templatenames = True
diff --git a/fedoracommunity/config/middleware.py b/fedoracommunity/config/middleware.py
index 57add69..9684702 100644
--- a/fedoracommunity/config/middleware.py
+++ b/fedoracommunity/config/middleware.py
@@ -16,12 +16,12 @@
from fedoracommunity.config.app_cfg import base_config
from fedoracommunity.config.environment import load_environment
-from paste.cascade import Cascade
make_base_app = base_config.setup_tg_wsgi_app(load_environment)
def make_app(global_conf, full_stack=True, **app_conf):
from moksha.middleware import make_moksha_middleware
+
app = make_base_app(global_conf, wrap_app=make_moksha_middleware,
full_stack=full_stack,
**app_conf)
diff --git a/fedoracommunity/connectors/__init__.py b/fedoracommunity/connectors/__init__.py
index 368e632..22006d5 100644
--- a/fedoracommunity/connectors/__init__.py
+++ b/fedoracommunity/connectors/__init__.py
@@ -9,3 +9,4 @@ from wikiconnector import WikiConnector
from torrentconnector import TorrentConnector
from jsonconnector import SimpleJsonConnector
from xapianconnector import XapianConnector
+from gitconnector import GitConnector
diff --git a/fedoracommunity/connectors/gitconnector.py b/fedoracommunity/connectors/gitconnector.py
new file mode 100644
index 0000000..5625020
--- /dev/null
+++ b/fedoracommunity/connectors/gitconnector.py
@@ -0,0 +1,142 @@
+# This file is part of Fedora Community.
+# Copyright (C) 2011 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import git
+import logging
+import subprocess
+
+from tg import config
+from kitchen.text.converters import to_unicode
+from pygments import highlight
+from pygments.lexers import DiffLexer, BashLexer
+from pygments.formatters import HtmlFormatter
+from moksha.lib.helpers import DateTimeDisplay
+from moksha.connector import IConnector, ICall, IQuery, ParamFilter
+
+log = logging.getLogger(__name__)
+
+class FedoraGitRepo(object):
+ """ An abstraction for working with packages in the Fedora Git repos """
+
+ def __init__(self, package, branch='master'):
+ self.package = package
+ self.branch = branch
+ top_repo = config.get('git_repo_path')
+ self.repo_path = os.path.join(top_repo, package, branch)
+ if not os.path.isdir(self.repo_path):
+ if not os.path.isdir(top_repo):
+ os.makedirs(top_repo)
+ self.clone_repo()
+ self.repo = git.Repo(self.repo_path)
+
+ def _run(self, cmd, **kw):
+ """ Run a shell command and return stdout.
+
+ If no `cwd` is specified, default to inside the repo for this
+ package & branch.
+ """
+ if 'cwd' not in kw:
+ kw['cwd'] = self.repo_path
+ p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, **kw)
+ out, err = p.communicate()
+ if out: log.debug(out)
+ if err: log.error(err)
+ return out
+
+ def clone_repo(self):
+ """ Create a fresh clone of this package's git repository """
+ self._run('fedpkg clone --anonymous --branches ' + self.package,
+ cwd=config.get('git_repo_path'))
+
+ def get_spec(self):
+ """ Return the contents of this package's RPM spec file """
+ return to_unicode(self.repo.tree()[self.package + '.spec'].data_stream.read())
+
+ def get_patches(self):
+ """ Return a dictionary of all patches for this package """
+ patches = {}
+ for patch in [blob for blob in self.repo.tree().traverse()
+ if blob.name.endswith('.patch')]:
+ created = self.get_creation_time(patch.name)
+ patches[patch.name] = [
+ DateTimeDisplay(created).age(granularity='day', general=True),
+ created.strftime('%d %b %Y'),
+ ]
+ return patches
+
+ def get_patch(self, patch):
+ """ Return the contents of a specific patch """
+ return to_unicode(self.repo.tree()[patch].data_stream.read())
+
+ def get_patch_changelog(self, patch):
+ """ Return a list of the changes made to this patch """
+ commits = []
+ current = {}
+ for commit in self.repo.git.log(patch).split('\n'):
+ chunks = commit.split()
+ if chunks:
+ if chunks[0] == 'commit':
+ if current:
+ commits.append(current)
+ current = {'msg': ''}
+ elif chunks[0] == 'Author:':
+ current['author'] = to_unicode(' '.join(chunks[1:]))
+ elif chunks[0] == 'Date:':
+ current['date'] = DateTimeDisplay(
+ ' '.join(chunks[1:-1]),
+ format='%a %b %d %H:%M:%S %Y').datetime
+ else:
+ current['msg'] += to_unicode('%s\n' %' '.join(chunks))
+ commits.append(current)
+ return commits
+
+ def get_diffstat(self, patch='*.patch'):
+ """ Return the output of diffstat on a given patch, or all patches """
+ return self._run('diffstat %s' % patch)
+
+ def get_creation_time(self, filename):
+ """ Return a datetime object for the date a given file was created """
+ date = ' '.join(self.repo.git.log(filename, reverse=True).split('\n')[2].split()[1:-1])
+ return DateTimeDisplay(date, format='%a %b %d %H:%M:%S %Y').datetime
+
+ def get_source_url(self):
+ return self._run('spectool -S *.spec').split()[1]
+
+ def get_fedora_source(self):
+ url = config.get('fedora_lookaside', 'http://pkgs.fedoraproject.org/repo/pkgs')
+ tarball = self.get_source_url().split('/')[-1]
+ md5 = self._run('grep %s sources' % tarball).split()[0]
+ url += '/%s/%s/%s/%s' % (self.package, tarball, md5, tarball)
+ return url
+
+
+class GitConnector(IConnector):
+ _method_paths = {}
+
+ def __init__(self, environ=None, request=None):
+ super(GitConnector, self).__init__(environ, request)
+
+ @classmethod
+ def register(cls):
+ cls.register_method('get_spec', cls.get_spec)
+
+ def get_spec(self, resource_path, _cookies=None, package=None, branch=None):
+ repo = FedoraGitRepo(package, branch=branch)
+ text = highlight(repo.get_spec(), BashLexer(),
+ HtmlFormatter(full=True, linenos=True, nobackground=True))
+ return {'text': text}
diff --git a/fedoracommunity/ctl/ctl.py b/fedoracommunity/ctl/ctl.py
index 864fd8d..8979296 100644
--- a/fedoracommunity/ctl/ctl.py
+++ b/fedoracommunity/ctl/ctl.py
@@ -181,6 +181,7 @@ def develop():
@_with_moksha_faked
def start(service='paster'):
""" Start paster. """
+ print("serving at http://127.0.0.1:8080")
return True
diff --git a/fedoracommunity/distutils/__init__.py b/fedoracommunity/distutils/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/fedoracommunity/distutils/__init__.py
diff --git a/fedoracommunity/distutils/command.py b/fedoracommunity/distutils/command.py
new file mode 100644
index 0000000..dca2443
--- /dev/null
+++ b/fedoracommunity/distutils/command.py
@@ -0,0 +1,13 @@
+
+import os
+import tg
+
+from paste.deploy import appconfig
+
+import tw2.core.command
+
+# hack to get all the tw2 widgets since we don't care about tw1
+config = appconfig('config:build.ini', relative_to=os.getcwd())
+tg.config = config
+print config.get('moksha.use_tw2')
+archive_fedoracommunity_resources = tw2.core.command.archive_tw2_resources
diff --git a/fedoracommunity/widgets/package/bugs.py b/fedoracommunity/widgets/package/bugs.py
index 65602d0..7f1b2a6 100644
--- a/fedoracommunity/widgets/package/bugs.py
+++ b/fedoracommunity/widgets/package/bugs.py
@@ -1,6 +1,6 @@
import tw2.core as twc
-from moksha.api.widgets import Grid
+from moksha.api.widgets.grid import TW2Grid
from moksha.api.connectors import get_connector
class BugStatsWidget(twc.Widget):
@@ -17,7 +17,7 @@ class BugStatsWidget(twc.Widget):
num_closed_this_week = twc.Param(default='')
-class BugsGrid(Grid):
+class BugsGrid(TW2Grid):
resource = 'bugzilla'
resource_path = 'query_bugs'
release_table = twc.Param()
diff --git a/fedoracommunity/widgets/package/builds.py b/fedoracommunity/widgets/package/builds.py
index f536a6e..30c71f5 100644
--- a/fedoracommunity/widgets/package/builds.py
+++ b/fedoracommunity/widgets/package/builds.py
@@ -1,7 +1,7 @@
import tw2.core as twc
-from moksha.api.widgets import Grid
+from moksha.api.widgets.grid import TW2Grid
-class BuildsGrid(Grid):
+class BuildsGrid(TW2Grid):
template='mako:fedoracommunity.widgets.package.templates.builds_table_widget'
resource='koji'
resource_path='query_builds'
diff --git a/fedoracommunity/widgets/package/changelog.py b/fedoracommunity/widgets/package/changelog.py
index 7f99359..a5646e3 100644
--- a/fedoracommunity/widgets/package/changelog.py
+++ b/fedoracommunity/widgets/package/changelog.py
@@ -1,9 +1,9 @@
import tw2.core as twc
-from moksha.api.widgets import Grid
+from moksha.api.widgets.grid import TW2Grid
from moksha.api.connectors import get_connector
from collections import OrderedDict
-class ChangelogGrid(Grid):
+class ChangelogGrid(TW2Grid):
template='mako:fedoracommunity.widgets.package.templates.changelog_table_widget'
resource='koji'
resource_path='query_changelogs'
diff --git a/fedoracommunity/widgets/package/contents.py b/fedoracommunity/widgets/package/contents.py
index a921da6..fafa3e7 100644
--- a/fedoracommunity/widgets/package/contents.py
+++ b/fedoracommunity/widgets/package/contents.py
@@ -1,5 +1,5 @@
import tw2.core as twc
-from moksha.api.widgets import Grid
+from moksha.api.widgets.grid import TW2Grid
from moksha.api.connectors import get_connector
from collections import OrderedDict
diff --git a/fedoracommunity/widgets/package/overview.py b/fedoracommunity/widgets/package/overview.py
index 9ba77b8..0b11bec 100644
--- a/fedoracommunity/widgets/package/overview.py
+++ b/fedoracommunity/widgets/package/overview.py
@@ -4,7 +4,7 @@ import collections
from package import TabWidget
from mako.template import Template
from moksha.api.connectors import get_connector
-from moksha.api.widgets import Grid
+from moksha.api.widgets.grid import TW2Grid
class OverviewNavWidget(TabWidget):
tabs = collections.OrderedDict([('Details', 'package.overview.details'),
@@ -21,7 +21,7 @@ class OverviewWidget(twc.Widget):
nav_widget = OverviewNavWidget
-class ActiveReleasesGrid(Grid):
+class ActiveReleasesGrid(TW2Grid):
template = 'mako:fedoracommunity.widgets.package.templates.active_releases'
package_name = twc.Param('The name of the package to view')
resource = 'bodhi'
diff --git a/fedoracommunity/widgets/package/relationships.py b/fedoracommunity/widgets/package/relationships.py
index 6119f8b..f5e5eb2 100644
--- a/fedoracommunity/widgets/package/relationships.py
+++ b/fedoracommunity/widgets/package/relationships.py
@@ -4,7 +4,7 @@ import collections
from package import TabWidget
from mako.template import Template
from moksha.api.connectors import get_connector
-from moksha.api.widgets import Grid
+from moksha.api.widgets.grid import TW2Grid
class RelationshipsNavWidget(TabWidget):
tabs = collections.OrderedDict([('Requires', 'package.relationships.requires'),
@@ -69,26 +69,26 @@ class RelationshipBaseWidget(twc.Widget):
build_info['arch_tasks'] = arch_tasks
self.build_to_archtask_map[build_info['build_id']] = arch_tasks
-class RequiresGridWidget(Grid):
- template = template = 'mako:fedoracommunity.widgets.package.templates.requires_table_widget'
+class RequiresGridWidget(TW2Grid):
+ template = 'mako:fedoracommunity.widgets.package.templates.requires_table_widget'
resource = 'koji'
resource_path = 'query_requires'
onReady = "update_grid()"
-class ProvidesGridWidget(Grid):
- template = template = 'mako:fedoracommunity.widgets.package.templates.provides_table_widget'
+class ProvidesGridWidget(TW2Grid):
+ template = 'mako:fedoracommunity.widgets.package.templates.provides_table_widget'
resource = 'koji'
resource_path = 'query_provides'
onReady = "update_grid()"
-class ObsoletesGridWidget(Grid):
- template = template = 'mako:fedoracommunity.widgets.package.templates.obsoletes_table_widget'
+class ObsoletesGridWidget(TW2Grid):
+ template = 'mako:fedoracommunity.widgets.package.templates.obsoletes_table_widget'
resource = 'koji'
resource_path = 'query_obsoletes'
onReady = "update_grid()"
-class ConflictsGridWidget(Grid):
- template = template = 'mako:fedoracommunity.widgets.package.templates.conflicts_table_widget'
+class ConflictsGridWidget(TW2Grid):
+ template = 'mako:fedoracommunity.widgets.package.templates.conflicts_table_widget'
resource = 'koji'
resource_path = 'query_conflicts'
onReady = "update_grid()"
diff --git a/fedoracommunity/widgets/package/sources.py b/fedoracommunity/widgets/package/sources.py
index 4bcb46b..1f2e19b 100644
--- a/fedoracommunity/widgets/package/sources.py
+++ b/fedoracommunity/widgets/package/sources.py
@@ -1,130 +1,83 @@
-import os
-import git
-import subprocess
+# This file is part of Fedora Community.
+# Copyright (C) 2011 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
import tw2.core as twc
-import logging
-from tg import config
from mako.template import Template
from collections import OrderedDict
-from moksha.lib.helpers import DateTimeDisplay
from pygments import highlight
-from pygments.lexers import DiffLexer
+from pygments.lexers import DiffLexer, BashLexer
from pygments.formatters import HtmlFormatter
-from kitchen.text.converters import to_unicode
+from moksha.api.connectors import get_connector
+from fedoracommunity.connectors.gitconnector import FedoraGitRepo
from package import TabWidget
-log = logging.getLogger(__name__)
-
-class FedoraGitRepo(object):
- """ An abstraction for working with packages in the Fedora Git repos """
-
- def __init__(self, package, branch='master'):
- self.package = package
- self.branch = branch
- top_repo = config.get('git_repo_path')
- self.repo_path = os.path.join(top_repo, package, branch)
- if not os.path.isdir(self.repo_path):
- if not os.path.isdir(top_repo):
- os.makedirs(top_repo)
- self.clone_repo()
- self.repo = git.Repo(self.repo_path)
-
- def _run(self, cmd, **kw):
- """ Run a shell command and return stdout.
-
- If no `cwd` is specified, default to inside the repo for this
- package & branch.
- """
- if 'cwd' not in kw:
- kw['cwd'] = self.repo_path
- p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE, **kw)
- out, err = p.communicate()
- if out: log.debug(out)
- if err: log.error(err)
- return out
-
- def clone_repo(self):
- """ Create a fresh clone of this package's git repository """
- self._run('fedpkg clone --anonymous --branches ' + self.package,
- cwd=config.get('git_repo_path'))
-
- def get_spec(self):
- """ Return the contents of this package's RPM spec file """
- return to_unicode(self.repo.tree()[self.package + '.spec'].data_stream.read())
-
- def get_patches(self):
- """ Return a dictionary of all patches for this package """
- patches = {}
- for patch in [blob for blob in self.repo.tree().traverse()
- if blob.name.endswith('.patch')]:
- created = self.get_creation_time(patch.name)
- patches[patch.name] = [
- DateTimeDisplay(created).age(granularity='day', general=True),
- created.strftime('%d %b %Y'),
- ]
- return patches
-
- def get_patch(self, patch):
- """ Return the contents of a specific patch """
- return to_unicode(self.repo.tree()[patch].data_stream.read())
-
- def get_patch_changelog(self, patch):
- """ Return a list of the changes made to this patch """
- commits = []
- current = {}
- in_commit = False
- for commit in self.repo.git.log(patch).split('\n'):
- chunks = commit.split()
- if chunks:
- if chunks[0] == 'commit':
- if current:
- commits.append(current)
- current = {'msg': ''}
- elif chunks[0] == 'Author:':
- current['author'] = to_unicode(' '.join(chunks[1:]))
- elif chunks[0] == 'Date:':
- current['date'] = DateTimeDisplay(
- ' '.join(chunks[1:-1]),
- format='%a %b %d %H:%M:%S %Y').datetime
- else:
- current['msg'] += to_unicode('%s\n' %' '.join(chunks))
- commits.append(current)
- return commits
-
- def get_diffstat(self, patch='*.patch'):
- """ Return the output of diffstat on a given patch, or all patches """
- return self._run('diffstat %s' % patch)
-
- def get_creation_time(self, filename):
- """ Return a datetime object for the date a given file was created """
- date = ' '.join(self.repo.git.log(filename, reverse=True).split('\n')[2].split()[1:-1])
- return DateTimeDisplay(date, format='%a %b %d %H:%M:%S %Y').datetime
-
-
class Sources(TabWidget):
tabs = OrderedDict([
('Spec', 'package.sources.spec'),
('Patches', 'package.sources.patches'),
- ('Diffs', 'package.sources.diffs'),
+ #('Diffs', 'package.sources.diffs'),
('Tarballs', 'package.sources.tarballs'),
- ('Git', 'package.sources.git'),
+ #('Git', 'package.sources.git'),
])
base_url = Template(text='/${kwds["package_name"]}/sources/')
default_tab = 'Spec'
+class ReleaseFilter(twc.Widget):
+ on_change = twc.Param('The name of the javascript function to call upon change')
+ template = 'mako:fedoracommunity.widgets.package.templates.release_filter'
+
+ def prepare(self):
+ super(ReleaseFilter, self).prepare()
+ releases = []
+ pkgdb = get_connector('pkgdb')
+ collections = pkgdb.get_collection_table(active_only=True)
+ for id, collection in collections.iteritems():
+ name = collection['name']
+ ver = collection['version']
+ label = "%s %s" % (name, ver)
+ value = ""
+ branchname = collection['gitbranchname']
+ if branchname:
+ value = branchname
+ if label != 'Fedora devel' and name in ('Fedora', 'Fedora EPEL'):
+ releases.append({
+ 'label': label,
+ 'value': value,
+ 'version': ver,
+ })
+ self.releases_table = sorted(releases,
+ cmp=lambda x, y: cmp(x['version'], y['version']))
+ self.releases_table.insert(0, {'label': 'Rawhide', 'value': 'master'})
+
+
class Spec(twc.Widget):
kwds = twc.Param(default=None)
text = twc.Param('The text of the specfile')
- template = 'mako:fedoracommunity/widgets/package/templates/package_spec.mak'
+ template = 'mako:fedoracommunity.widgets.package.templates.package_spec'
+ releases = ReleaseFilter
def prepare(self):
super(Spec, self).prepare()
- repo = FedoraGitRepo(self.kwds['package_name'])
- self.text = repo.get_spec()
+ self.package_name = self.kwds['package_name']
+ repo = FedoraGitRepo(self.package_name)
+ self.text = highlight(repo.get_spec(), BashLexer(),
+ HtmlFormatter(full=True, linenos=True, nobackground=True))
class Patches(twc.Widget):
@@ -132,7 +85,7 @@ class Patches(twc.Widget):
patches = twc.Param(default=None)
package = twc.Variable()
diffstat = twc.Variable()
- template = 'mako:fedoracommunity/widgets/package/templates/patches.mak'
+ template = 'mako:fedoracommunity.widgets.package.templates.patches'
def prepare(self):
super(Patches, self).prepare()
@@ -148,7 +101,7 @@ class Patch(twc.Widget):
diffstat = twc.Param('The diffstat for this patch', default=True)
text = twc.Variable('The text of the patch')
changelog = twc.Variable('The changelog of this patch')
- template = 'mako:fedoracommunity/widgets/package/templates/patch.mak'
+ template = 'mako:fedoracommunity.widgets.package.templates.patch'
def prepare(self):
super(Patch, self).prepare()
@@ -162,21 +115,27 @@ class Patch(twc.Widget):
class Diffs(twc.Widget):
- template = 'mako:fedoracommunity/widgets/package/templates/diffs.mak'
+ template = 'mako:fedoracommunity.widgets.package.templates.diffs'
def prepare(self):
super(Diffs, self).prepare()
class Tarballs(twc.Widget):
- template = 'mako:fedoracommunity/widgets/package/templates/tarballs.mak'
+ template = 'mako:fedoracommunity.widgets.package.templates.tarballs'
+ package = twc.Param('The name of the package')
+ upstream_tarball = twc.Variable()
kwds = twc.Param(default=None)
def prepare(self):
super(Tarballs, self).prepare()
+ self.package = self.kwds['package_name']
+ repo = FedoraGitRepo(self.package)
+ self.upstream_tarball = repo.get_source_url()
+ self.fedora_tarball = repo.get_fedora_source()
class GitRepo(twc.Widget):
- template = 'mako:fedoracommunity/widgets/package/templates/git.mak'
+ template = 'mako:fedoracommunity.widgets.package.templates.git'
kwds = twc.Param(default=None)
def prepare(self):
diff --git a/fedoracommunity/widgets/package/templates/contents.mak b/fedoracommunity/widgets/package/templates/contents.mak
index 7d73b93..089bb04 100644
--- a/fedoracommunity/widgets/package/templates/contents.mak
+++ b/fedoracommunity/widgets/package/templates/contents.mak
@@ -3,7 +3,7 @@
<form>
<div id="filter" class="grid_filter" name="build_filter">
- <!-- BEGIN Arch Dropdown Filter **/ -->
+ <!-- BEGIN Release Dropdown Filter **/ -->
<div class="filter grid_9 alpha">
<label for="build_id"><h4>Release:</h4></label>
<script type="text/javascript">
diff --git a/fedoracommunity/widgets/package/templates/package_spec.mak b/fedoracommunity/widgets/package/templates/package_spec.mak
index 43222b3..a3a3f0d 100644
--- a/fedoracommunity/widgets/package/templates/package_spec.mak
+++ b/fedoracommunity/widgets/package/templates/package_spec.mak
@@ -1,2 +1,22 @@
+<script type="text/javascript">
+
+function done_cb(data) {
+ $('#specfile').html(data['text']);
+}
+
+function on_change(self) {
+ moksha.connector_load('git', 'get_spec', {
+ 'package': '${w.package_name}',
+ 'branch': self.value
+ }, done_cb);
+}
+
+</script>
+
+${w.children[0].display(package=w.package_name, on_change='on_change')}
+
<br/>
-<pre>${w.text}</pre>
+
+<div id="specfile">
+${w.text}
+</div>
diff --git a/fedoracommunity/widgets/package/templates/release_filter.mak b/fedoracommunity/widgets/package/templates/release_filter.mak
new file mode 100644
index 0000000..7c1a62f
--- /dev/null
+++ b/fedoracommunity/widgets/package/templates/release_filter.mak
@@ -0,0 +1,6 @@
+<select name="release_id" id="release_select" onChange="${w.on_change}(this)">
+ % for i, release in enumerate(w.releases_table):
+ <% selected = i == 0 and 'selected="selected"' or '' %>
+ <option ${selected} value="${str(release['value'])}">${release['label']}</option>
+ % endfor
+</select>
diff --git a/fedoracommunity/widgets/package/templates/tarballs.mak b/fedoracommunity/widgets/package/templates/tarballs.mak
index 1333ed7..3241cf2 100644
--- a/fedoracommunity/widgets/package/templates/tarballs.mak
+++ b/fedoracommunity/widgets/package/templates/tarballs.mak
@@ -1 +1,6 @@
-TODO
+<h2>Upstream Tarball</h2>
+<a href="${w.upstream_tarball}">${w.upstream_tarball}</a>
+<br/>
+<br/>
+<h2>Fedora Look-aside Tarball</h2>
+<a href="${w.fedora_tarball}">${w.fedora_tarball}</a>
diff --git a/fedoracommunity/widgets/package/updates.py b/fedoracommunity/widgets/package/updates.py
index 1868c02..e47ba2e 100644
--- a/fedoracommunity/widgets/package/updates.py
+++ b/fedoracommunity/widgets/package/updates.py
@@ -1,12 +1,12 @@
import tw2.core as twc
-from moksha.api.widgets import Grid
+from moksha.api.widgets.grid import TW2Grid
from moksha.api.connectors import get_connector
bodhi_js = twc.JSLink(filename='static/javascript/bodhi.js',
modname=__name__)
-class Updates(Grid):
+class Updates(TW2Grid):
template = 'mako:fedoracommunity.widgets.package.templates.updates_table_widget'
kwds = twc.Param()
package_name = twc.Param('The name of the package to view')
diff --git a/fedoracommunity/widgets/widgets.py b/fedoracommunity/widgets/widgets.py
index 43a3783..457dd17 100644
--- a/fedoracommunity/widgets/widgets.py
+++ b/fedoracommunity/widgets/widgets.py
@@ -15,13 +15,21 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import tw2.core as twc
+from tw2.core.params import Param
+from tg.controllers import url
-fedora_css = twc.CSSLink(modname='fedoracommunity', filename='/public/css/fedora.css')
-fedoracommunity_appchrome_css = twc.CSSLink(modname='fedoracommunity', filename='/public/css/application-chrome.css')
-fedoracommunity_branding_css = twc.CSSLink(modname='fedoracommunity', filename='/public/css/myfedora-branding.css')
-fedoracommunity_reset_css = twc.CSSLink(modname='fedoracommunity', filename='/public/css/reset.css')
-fedoracommunity_text_css = twc.CSSLink(modname='fedoracommunity', filename='/public/css/text.css')
-fedoracommunity_960_24_col_css = twc.CSSLink(modname='fedoracommunity', filename='/public/css/960_24_col.css')
+class CSSLink(twc.CSSLink):
+ path = Param('Path to where you would find these files on the web server')
+ def prepare(self):
+ self.link = url(self.path)
+ super(CSSLink, self).prepare()
+
+fedora_css = CSSLink(modname='fedoracommunity', path='/css/fedora.css')
+fedoracommunity_appchrome_css = CSSLink(modname='fedoracommunity', path='/css/application-chrome.css')
+fedoracommunity_branding_css = CSSLink(modname='fedoracommunity', path='/css/myfedora-branding.css')
+fedoracommunity_reset_css = CSSLink(modname='fedoracommunity', path='/css/reset.css')
+fedoracommunity_text_css = CSSLink(modname='fedoracommunity', path='/css/text.css')
+fedoracommunity_960_24_col_css = CSSLink(modname='fedoracommunity', path='/css/960_24_col.css')
class PagerWidget(twc.Widget):
diff --git a/orbited.cfg b/orbited.cfg
deleted file mode 100644
index dc580cc..0000000
--- a/orbited.cfg
+++ /dev/null
@@ -1,7 +0,0 @@
-[global]
-proxy.enabled = 1
-proxy.keepalive = 0
-
-[proxy]
-/feed -> ORBITED
-/ -> http://127.0.0.1:8080
diff --git a/setup.py b/setup.py
index 9bdd43f..5774d2a 100755
--- a/setup.py
+++ b/setup.py
@@ -112,6 +112,7 @@ setup(
xapian = fedoracommunity.connectors:XapianConnector
wiki = fedoracommunity.connectors:WikiConnector
torrent = fedoracommunity.connectors:TorrentConnector
+ git = fedoracommunity.connectors:GitConnector
[moksha.widget]
fedoracommunity.bodhi = fedoracommunity.widgets.bodhi:bodhi_js
@@ -147,5 +148,8 @@ setup(
[moksha.extension_point]
fedoracommunity = fedoracommunity.plugins.extensions
+ [distutils.commands]
+ archive_fedoracommunity_resources = fedoracommunity.distutils.command:archive_fedoracommunity_resources
+
"""
)