diff --git a/apps/base/templates/admin.html b/apps/base/templates/admin.html
index 42f8d5ca..c4530020 100644
--- a/apps/base/templates/admin.html
+++ b/apps/base/templates/admin.html
@@ -1,31 +1,66 @@
{% extends 'base.html' %}
-{% block title %}Mozilla FlightDeck Admin Area{% endblock title %}
+{% block title %}Mozilla FlightDeck Admin Area - {% endblock title %}
{% block head_prejs %}
{% endblock %}
-{% block app_content %}
-
+{% block head %}
+
+
+{% endblock %}
+
+{% block app_content %}
+
+
+
+
+
Package
+
+
+
+
{% endblock %}
diff --git a/apps/base/templates/admin/_package_result.html b/apps/base/templates/admin/_package_result.html
new file mode 100644
index 00000000..e729ffc2
--- /dev/null
+++ b/apps/base/templates/admin/_package_result.html
@@ -0,0 +1,21 @@
+
+
diff --git a/apps/base/templates/monitor.html b/apps/base/templates/monitor.html
index f3bb7771..9ac012a6 100644
--- a/apps/base/templates/monitor.html
+++ b/apps/base/templates/monitor.html
@@ -29,8 +29,8 @@
Free space
- {% for path, size in free.items() %}
- - {{ path }}: {{ size }}kB
+ {% for path, size in free %}
+ - {{ path }}: {{ size|filesizeformat }}
{% endfor %}
diff --git a/apps/base/urls.py b/apps/base/urls.py
index b11cb79f..cf0751d7 100644
--- a/apps/base/urls.py
+++ b/apps/base/urls.py
@@ -8,4 +8,6 @@ urlpatterns = patterns('',
url('^services/monitor$', 'base.views.monitor', name='monitor'),
url('^services/settings$', 'base.views.site_settings', name='settings'),
url('^services/admin$', 'base.views.admin', name='admin_triggers'),
+ url('^services/admin/package$', 'base.views.get_package', name='admin_get_package'),
+ url('^services/admin/package/update$', 'base.views.update_package', name='admin_update_package'),
)
diff --git a/apps/base/views.py b/apps/base/views.py
index 5fe93db4..b73e5c24 100644
--- a/apps/base/views.py
+++ b/apps/base/views.py
@@ -6,9 +6,10 @@ import commonware.log
from django.conf import settings
from django.contrib.auth.decorators import user_passes_test
from django.http import HttpResponse
-from django.shortcuts import render_to_response
+from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext, loader
from django.views.debug import get_safe_settings
+from django.template.loader import get_template
from elasticutils import get_es
import base.tasks
@@ -130,10 +131,10 @@ def monitor(request):
s_path = '%s/' % settings.SDKDIR_PREFIX
x = os.statvfs(x_path)
s = os.statvfs(s_path)
- data['free'] = {
- 'xpi_targetdir %s' % x_path: (x.f_bavail * x.f_frsize) / 1024,
- 'sdkdir_prefix %s' % s_path: (s.f_bavail * s.f_frsize) / 1024
- }
+ data['free'] = [
+ ('xpi_targetdir %s' % x_path, x.f_bavail * x.f_frsize),
+ ('sdkdir_prefix %s' % s_path, s.f_bavail * s.f_frsize)
+ ]
data['filepaths'] = filepath_results
@@ -190,13 +191,31 @@ def monitor(request):
# Check Redis
# TODO: we don't currently use redis
-
context = RequestContext(request, data)
status = 200 if status else 500
template = loader.get_template('monitor.html')
return HttpResponse(template.render(context), status=status)
+def get_package(request):
+ package = get_object_or_404(Package, pk=request.GET['package_id'])
+ return render_to_response('admin/_package_result.html', {
+ 'package': package
+ }, context_instance=RequestContext(request))
+
+@user_passes_test(lambda u: u.is_superuser)
+def update_package(request):
+ package = get_object_or_404(Package, pk=request.POST['package_id'])
+ if 'featured' in request.POST:
+ package.featured = request.POST.get('featured') == 'true'
+
+ if 'example' in request.POST:
+ package.example = request.POST.get('example') == 'true'
+
+ package.save()
+ return HttpResponse({'status':'ok'}, content_type='text/javascript')
+
+
def homepage(r):
# one more for the main one
addons_limit = settings.HOMEPAGE_PACKAGES_NUMBER
@@ -216,6 +235,7 @@ def homepage(r):
context_instance=RequestContext(r))
+
def robots(request):
data = "User-agent: *\n"
if not settings.ENGAGE_ROBOTS:
diff --git a/apps/jetpack/models.py b/apps/jetpack/models.py
index b1774661..38e6f160 100644
--- a/apps/jetpack/models.py
+++ b/apps/jetpack/models.py
@@ -1496,6 +1496,10 @@ class Package(BaseModel, SearchMixin):
active = models.BooleanField(default=True, blank=True)
# deleted is the limbo state
deleted = models.BooleanField(default=False, blank=True)
+ # is an example package
+ example = models.BooleanField(default=False, blank=True)
+ # is a featured package
+ featured = models.BooleanField(default=False, blank=True)
#package activity score
activity_rating = models.DecimalField(default=Decimal('0.0'), max_digits=4, decimal_places=3)
diff --git a/apps/search/templates/_package_result.html b/apps/search/templates/_package_result.html
index d74d8c5f..955f96b4 100644
--- a/apps/search/templates/_package_result.html
+++ b/apps/search/templates/_package_result.html
@@ -2,21 +2,26 @@
{{ package.full_name }}
-
+ {% if package.featured %}
+ featured
+ {% endif %}
+ {% if package.example %}
+ example
+ {% endif %}
{{ package.description }}
diff --git a/media/base/js/Admin.js b/media/base/js/Admin.js
new file mode 100644
index 00000000..4a5dfb25
--- /dev/null
+++ b/media/base/js/Admin.js
@@ -0,0 +1,53 @@
+window.addEvent('domready', function(e){
+ var setMsg = function(msg){
+ var elem = $('package_msg');
+ elem.set('html', msg);
+ setTimeout(function(){
+ elem.set('html','');
+ },2000);
+ }
+ $('btn_find_package').addEvent('click', function(e){
+ var r = new Request({
+ url: admin_settings.get_package_url,
+ onSuccess: function(p){
+ $('package_item').set('html',p);
+ },
+ onFailure: function(err){
+ console.log(err);
+ setMsg(err.status + " " + err.statusText);
+ }
+ });
+ r.get('package_id='+ $('txt_package_id').value);
+
+ });
+
+ var updatePackage = function(elem, field, callback){
+ var id = elem.getParent('.package').getElement('.package_id').value,
+ enabled = elem.getParent().hasClass('pressed'),
+ r = new Request({
+ url: admin_settings.update_package_url,
+ method: 'post',
+ onSuccess: function(p){
+ setMsg("updated");
+ elem.getParent().toggleClass('pressed');
+ if (callback) callback();
+ },
+ onFailure: function(err){
+ if(err.status == 404){
+ $('package_item').set('html', '');
+ }
+ setMsg(err.status + " " + err.statusText);
+ }
+ });
+ r.send('package_id='+id+'&'+field+'='+!enabled);
+ };
+
+ $('package_item').addEvent('click:relay(.UI_Package_Featured a)', function(e){
+ e.stop();
+ updatePackage(this, 'featured')
+ });
+ $('package_item').addEvent('click:relay(.UI_Package_Example a)', function(e){
+ e.stop();
+ updatePackage(this, 'example')
+ });
+});
\ No newline at end of file
diff --git a/media/lib/shipyard b/media/lib/shipyard
index 85f0e6f7..ab0f4bd7 160000
--- a/media/lib/shipyard
+++ b/media/lib/shipyard
@@ -1 +1 @@
-Subproject commit 85f0e6f71ffeeb104f20da889c1f1a5edea624a1
+Subproject commit ab0f4bd7077e1dfdba70bbdaea1be83d14405b83
diff --git a/media/search/css/Search.css b/media/search/css/Search.css
index 14e655ad..a1e66d2a 100644
--- a/media/search/css/Search.css
+++ b/media/search/css/Search.css
@@ -160,7 +160,8 @@ body {
color:#2854BB;
/*color:#478CDE;*/
font-size:1.3em;
- letter-spacing: -0.5px;
+ letter-spacing: -0.5px;
+ margin-right:10px;
}
#SearchResults .package h3 span {
@@ -192,12 +193,53 @@ body {
}
#SearchResults .package ul.search_meta li{
float:left;
- color:#444;
- margin-right:10px;
+ color:#444;
+ margin-right:5px;
}
- #SearchResults .package ul.search_meta li span{
- color:#666;
+ #SearchResults .package ul.search_meta li span{
+ opacity: 0.35;
+ padding-right: 10px;
+ }
+
+ #SearchResults .package ul.search_meta li.size span{
+ background-image:url('../img/size.png');
+ background-repeat: no-repeat;
+ }
+ #SearchResults .package ul.search_meta li.size{
+ width:75px;
+ }
+
+ #SearchResults .package ul.search_meta li.author span{
+ background-image:url('../img/person.png');
+ background-repeat: no-repeat;
+ }
+ #SearchResults .package ul.search_meta li.author{
+ width:100px;
+ }
+
+ #SearchResults .package ul.search_meta li.forks span{
+ background-image:url('../img/fork.png');
+ background-repeat: no-repeat;
+ }
+ #SearchResults .package ul.search_meta li.forks{
+ width: 42px;
+ }
+
+ #SearchResults .package ul.search_meta li.used span{
+ background-image:url('../img/bookmark.png');
+ background-repeat: no-repeat;
+ }
+ #SearchResults .package ul.search_meta li.used{
+ width: 52px;
+ }
+
+ #SearchResults .package ul.search_meta li.activity span{
+ background-image:url('../img/chart.png');
+ background-repeat: no-repeat;
+ }
+ #SearchResults .package ul.search_meta li.activity{
+ width: 65px;
}
#SearchResults .UI_Sorting{
@@ -209,7 +251,30 @@ body {
font-size:0.8em;
}
-
+#SearchResults .featured{
+ background: -moz-linear-gradient(center top , #D3B000 0%, #CC952E 100%) repeat scroll 0 0 transparent;
+ border: 1px solid #AD8027;
+ border-radius: 2px 2px 2px 2px;
+ color: white !important;
+ font-size: 0.7em;
+ font-weight: bold;
+ padding: 2px 5px 2px 6px;
+ position: relative;
+ text-shadow: 0 -1px 0 #AD8027;
+ top: -3px;
+}
+#SearchResults .example{
+ background: -moz-linear-gradient(center top , #638ced 0%, #2170ef 100%) repeat scroll 0 0 transparent;
+ border: 1px solid #2170ef;
+ border-radius: 2px 2px 2px 2px;
+ color: white !important;
+ font-size: 0.7em;
+ font-weight: bold;
+ padding: 2px 5px 2px 6px;
+ position: relative;
+ text-shadow: 0 -1px 0 #2170ef;
+ top: -3px;
+}
#SearchResults .see-more {
diff --git a/media/search/img/bookmark.png b/media/search/img/bookmark.png
new file mode 100644
index 00000000..acd97200
Binary files /dev/null and b/media/search/img/bookmark.png differ
diff --git a/media/search/img/chart.png b/media/search/img/chart.png
new file mode 100755
index 00000000..eeb514ea
Binary files /dev/null and b/media/search/img/chart.png differ
diff --git a/media/search/img/fork.png b/media/search/img/fork.png
new file mode 100755
index 00000000..a8dbfd97
Binary files /dev/null and b/media/search/img/fork.png differ
diff --git a/media/search/img/person.png b/media/search/img/person.png
new file mode 100755
index 00000000..b275d9e5
Binary files /dev/null and b/media/search/img/person.png differ
diff --git a/media/search/img/size.png b/media/search/img/size.png
new file mode 100755
index 00000000..45231762
Binary files /dev/null and b/media/search/img/size.png differ
diff --git a/migrations/026-add_featured_example_package_flags.sql b/migrations/026-add_featured_example_package_flags.sql
new file mode 100644
index 00000000..d2555ca7
--- /dev/null
+++ b/migrations/026-add_featured_example_package_flags.sql
@@ -0,0 +1,2 @@
+ALTER TABLE `jetpack_package` ADD `featured` BOOLEAN DEFAULT FALSE;
+ALTER TABLE `jetpack_package` ADD `example` BOOLEAN DEFAULT FALSE;
\ No newline at end of file