Commits

Mario César Señoranis Ayala committed d28fb8b

Fix static url for views

  • Participants
  • Parent commits 5ed9fa5

Comments (0)

Files changed (7)

File example/static/style-django_style.css

+.page-header {
+    margin-bottom: 2em;
+}
+
+dt {
+    width: 15em;
+    padding: .5em;
+    float: left;
+    margin: 0;
+    font-weight: bold;
+    clear:left;
+}
+dd {
+    margin-left: 16em;
+    padding: .5em;
+}
+
+table#changes_list {
+    table-layout:fixed;
+}
+td {
+    overflow: hidden;
+    white-space:nowrap;
+}
+
+.description {
+  background-color: #FEFFAA;
+  color: #000000;
+  padding: 1em;
+  margin: 0;
+}
+
+span.logtags span {
+  padding: 0px 6px;
+  font-weight: normal;
+  font-size: 11px;
+  border: 1px solid;
+  background-color: #ffaaff;
+  border-color: #ffccff #ff00ee #ff00ee #ffccff;
+}
+span.logtags span.tagtag {
+  background-color: #ffffaa;
+  border-color: #ffffcc #ffee00 #ffee00 #ffffcc;
+}
+span.logtags span.branchtag {
+  background-color: #aaffaa;
+  border-color: #ccffcc #00cc33 #00cc33 #ccffcc;
+}
+span.logtags span.inbranchtag {
+  background-color: #d5dde6;
+  border-color: #e3ecf4 #9398f4 #9398f4 #e3ecf4;
+}
+
+div.diff pre {
+  margin: 10px 0 0 0 !important;
+}
+div.diff pre span {
+  font-family: monospace;
+  white-space: pre;
+  font-size: 1.2em;
+  padding: 3px 0  !important;
+}
+
+td.source {
+  white-space: pre;
+  font-family: monospace;
+}
+  div.source {
+    font-size: 1.2em;
+  }
+.linenr {
+  color: #999;
+  text-align: right;
+}
+.lineno {
+  text-align: right;
+}
+.lineno a {
+  color: #999;
+}
+td.linenr {
+  width: 10px;
+}
+
+div#powered-by {
+  position: absolute;
+  width: 75px;
+  top: 15px;
+  right: 20px;
+  font-size: 1.2em;
+}
+div#powered-by a {
+  color: #EEE;
+  text-decoration: none;
+}
+div#powered-by a:hover {
+  text-decoration: underline;
+}
+
+/** file **/
+p.files {
+  margin: 0 0 0 20px;
+  font-size: 2.0em;
+  font-weight: bold;
+}
+/** end of file **/
+
+/** canvas **/
+div#wrapper {
+	position: relative;
+    font-size: 1.2em;
+}
+
+canvas {
+	position: absolute;
+	z-index: 5;
+	top: -0.7em;
+}
+
+ul#nodebgs li.parity0 {
+    background: #F1F6F7;
+}
+
+ul#nodebgs li.parity1 {
+    background: #FFFFFF;
+}
+
+ul#graphnodes {
+	position: absolute;
+	z-index: 10;
+	top: 7px;
+	padding:0 0 0 1em;
+	margin: 0;
+	list-style: none inside none;
+}
+ul#nodebgs li, ul#graphnodes li {
+	list-style: none inside none !important;
+}
+
+ul#nodebgs {
+	list-style: none inside none !important;
+}
+
+ul#graphnodes li, ul#nodebgs li {
+	height: 39px;
+}
+
+ul#graphnodes li .info {
+	display: block;
+	position: relative;
+}
+/** end of canvas **/

File example/static/style-monoblue.css

-.page-header {
-    margin-bottom: 2em;
-}
-
-dt {
-    width: 15em;
-    padding: .5em;
-    float: left;
-    margin: 0;
-    font-weight: bold;
-    clear:left;
-}
-dd {
-    margin-left: 16em;
-    padding: .5em;
-}
-
-table#changes_list {
-    table-layout:fixed;
-}
-td {
-    overflow: hidden;
-    white-space:nowrap;
-}
-
-.description {
-  background-color: #FEFFAA;
-  color: #000000;
-  padding: 1em;
-  margin: 0;
-}
-
-span.logtags span {
-  padding: 0px 6px;
-  font-weight: normal;
-  font-size: 11px;
-  border: 1px solid;
-  background-color: #ffaaff;
-  border-color: #ffccff #ff00ee #ff00ee #ffccff;
-}
-span.logtags span.tagtag {
-  background-color: #ffffaa;
-  border-color: #ffffcc #ffee00 #ffee00 #ffffcc;
-}
-span.logtags span.branchtag {
-  background-color: #aaffaa;
-  border-color: #ccffcc #00cc33 #00cc33 #ccffcc;
-}
-span.logtags span.inbranchtag {
-  background-color: #d5dde6;
-  border-color: #e3ecf4 #9398f4 #9398f4 #e3ecf4;
-}
-
-div.diff pre {
-  margin: 10px 0 0 0 !important;
-}
-div.diff pre span {
-  font-family: monospace;
-  white-space: pre;
-  font-size: 1.2em;
-  padding: 3px 0  !important;
-}
-
-td.source {
-  white-space: pre;
-  font-family: monospace;
-}
-  div.source {
-    font-size: 1.2em;
-  }
-.linenr {
-  color: #999;
-  text-align: right;
-}
-.lineno {
-  text-align: right;
-}
-.lineno a {
-  color: #999;
-}
-td.linenr {
-  width: 10px;
-}
-
-div#powered-by {
-  position: absolute;
-  width: 75px;
-  top: 15px;
-  right: 20px;
-  font-size: 1.2em;
-}
-div#powered-by a {
-  color: #EEE;
-  text-decoration: none;
-}
-div#powered-by a:hover {
-  text-decoration: underline;
-}
-
-/** file **/
-p.files {
-  margin: 0 0 0 20px;
-  font-size: 2.0em;
-  font-weight: bold;
-}
-/** end of file **/
-
-/** canvas **/
-div#wrapper {
-	position: relative;
-    font-size: 1.2em;
-}
-
-canvas {
-	position: absolute;
-	z-index: 5;
-	top: -0.7em;
-}
-
-ul#nodebgs li.parity0 {
-    background: #F1F6F7;
-}
-
-ul#nodebgs li.parity1 {
-    background: #FFFFFF;
-}
-
-ul#graphnodes {
-	position: absolute;
-	z-index: 10;
-	top: 7px;
-	padding:0 0 0 1em;
-	margin: 0;
-	list-style: none inside none;
-}
-ul#nodebgs li, ul#graphnodes li {
-	list-style: none inside none !important;
-}
-
-ul#nodebgs {
-	list-style: none inside none !important;
-}
-
-ul#graphnodes li, ul#nodebgs li {
-	height: 39px;
-}
-
-ul#graphnodes li .info {
-	display: block;
-	position: relative;
-}
-/** end of canvas **/

File example/templates/hgwebproxy/wrapper.html

 {% block extrastyle %}
   {{ block.super }}
   <link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/changelists.css" />
-  <link rel="stylesheet" type="text/css" href="{{ static_url }}style-monoblue.css" />
+  <link rel="stylesheet" type="text/css" href="{{ static_url }}style-django_style.css" />
 {% endblock %}
 {% block bodyclass %}change-list{% endblock %}
 {% block coltype %}flex{% endblock %}

File example/urls.py

 from django.conf.urls.defaults import *
 from django.contrib import admin
 from django.conf import settings
+from hgwebproxy import settings as hgwebproxy_settings
 
 admin.autodiscover()
 
 
 if settings.DEBUG:
     urlpatterns += patterns('',
-        (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
+        (r'^static/(?P<path>.*)$', 'django.views.static.serve', 
+            {'document_root': hgwebproxy_settings.STATIC_PATH}),
     )

File hgwebproxy/models.py

     def save(self, *args, **kwargs):
         if not self.id:
             #TODO: Raise Exception if can't create repository
-            create_repository(self.location)
+            if create_repository(self.location):
+                raise Exception("Can't create repository")
+                
         super(Repository, self).save(*args, **kwargs)
-
+    
     def delete(self, *args, **kwargs):
         if not self.id:
             delete_repository(self.location)

File hgwebproxy/settings.py

 import os
 from django.conf import settings
 
-STATIC_URL   = getattr(settings, 'HGWEBPROXY_STATIC_URL', os.path.join(settings.MEDIA_URL, 'hg/'))
+STATIC_URL   = getattr(settings, 'HGWEBPROXY_STATIC_URL', settings.MEDIA_URL)
+STATIC_PATH   = getattr(settings, 'HGWEBPROXY_STATIC_PATH', os.path.join(settings.MEDIA_ROOT, '../static/'))
 STYLES_PATH  = getattr(settings, 'HGWEBPROXY_STYLE_PATH', None)

File hgwebproxy/views.py

     context = {
         'content': response.content,
         'reponame' : hgserve.reponame,
+        'static_url' : hgwebproxy_settings.STATIC_URL,
         'slugpath': request.path.replace(repo.get_absolute_url(), ''),
         'is_root': request.path == repo.get_absolute_url(),
         'repo': repo,