← Back to team overview

graphite-dev team mailing list archive

[Merge] lp:~jdugan-x1024/graphite/esnet-tweaks into lp:graphite

 

jdugan has proposed merging lp:~jdugan-x1024/graphite/esnet-tweaks into lp:graphite.

Requested reviews:
  graphite-dev (graphite-dev)

For more details, see:
https://code.launchpad.net/~jdugan-x1024/graphite/esnet-tweaks/+merge/57403

Let's try this again.  I got the merge request backwards last time...


Several relatively minor tweaks:

1. make all internal URL references relative to allow graphite to be installed somewhere other than the root of the server
2. create a setting for location of graphTemplates.conf and put it with other config files by default
3. allow local_settings.py to override TEMPLATE_DIRS, ADMINS, MANAGERS
4. the %P strftime() cookie is a GNU extension, use POSIX %p instead


My patch to make the URL reference relative was merged some time back but parts of it have regressed over time.  Hence #1.  This is by far the most invasive patch but I think I got it right.

#2 is basically cosmetic.  it was inspired by the location of the dashboard.conf file

#3 in my deployment I need to override these settings.

#4 comes from the fact that we deploy to FreeBSD and %P does not work there.
-- 
https://code.launchpad.net/~jdugan-x1024/graphite/esnet-tweaks/+merge/57403
Your team graphite-dev is requested to review the proposed merge of lp:~jdugan-x1024/graphite/esnet-tweaks into lp:graphite.
=== renamed file 'webapp/graphite/render/graphTemplates.conf' => 'conf/graphTemplates.conf'
=== modified file 'webapp/content/js/dashboard.js'
--- webapp/content/js/dashboard.js	2011-04-12 03:07:33 +0000
+++ webapp/content/js/dashboard.js	2011-04-12 21:48:31 +0000
@@ -16,7 +16,7 @@
 var NOT_EDITABLE = ['from', 'until', 'width', 'height', 'target', 'uniq'];
 
 var cookieProvider = new Ext.state.CookieProvider({
-  path: "/dashboard"
+  path: "../dashboard"
 });
 
 var NAV_BAR_REGION = cookieProvider.get('navbar-region') || 'west';
@@ -62,7 +62,7 @@
 ]);
 
 var contextFieldStore = new Ext.data.JsonStore({
-  url: '/metrics/find/',
+  url: '../metrics/find/',
   root: 'metrics',
   idProperty: 'name',
   fields: ContextFieldValueRecord,
@@ -573,7 +573,7 @@
   }
 
   var loader = new Ext.tree.TreeLoader({
-    url: '/metrics/find/',
+    url: '../metrics/find/',
     requestMethod: 'GET',
     listeners: {beforeload: setParams}
   });
@@ -624,7 +624,7 @@
     var record = new GraphRecord({
       target: target,
       params: myParams,
-      url: '/render?' + Ext.urlEncode(urlParams)
+      url: '../render?' + Ext.urlEncode(params)
     });
     graphStore.add([record]);
   }
@@ -638,7 +638,7 @@
     Ext.apply(params, this.data.params);
     Ext.apply(params, GraphSize);
     params.uniq = Math.random();
-    this.set('url', '/render?' + Ext.urlEncode(params));
+    this.set('url', '../render?' + Ext.urlEncode(this.get('params')));
   });
   graphView.refresh();
   graphArea.getTopToolbar().get('last-refreshed-text').setText( (new Date()).format('g:i:s A') );
@@ -649,7 +649,7 @@
   var node = graphView.getNode(index);
   var record = graphView.getRecord(node);
   record.data.params.uniq = Math.random();
-  record.set('url', '/render?' + Ext.urlEncode(record.get('params')));
+  record.set('url', '../render?' + Ext.urlEncode(record.get('params')));
 
   // This refreshNode method only refreshes the record data, it doesn't re-render
   // the template. Which is pretty useless... It would be more efficient if we
@@ -976,7 +976,7 @@
 function doShare() {
   if (dashboardName == null) {
     Ext.Ajax.request({
-      url: "/dashboard/create-temporary/",
+      url: "../dashboard/create-temporary/",
       method: 'POST',
       params: {
         state: Ext.encode( getState() )
@@ -1148,7 +1148,7 @@
 
 function breakoutGraph(record) {
   Ext.Ajax.request({
-    url: '/metrics/expand/',
+    url: '../metrics/expand/',
     params: {
       query: record.data.params.target
     },
@@ -1281,7 +1281,7 @@
 
 function sendSaveRequest(name) {
   Ext.Ajax.request({
-    url: "/dashboard/save/" + name,
+    url: "../dashboard/save/" + name,
     method: 'POST',
     params: {
       state: Ext.encode( getState() )
@@ -1298,7 +1298,7 @@
 
 function sendLoadRequest(name) {
   Ext.Ajax.request({
-    url: "/dashboard/load/" + name,
+    url: "../dashboard/load/" + name,
     success: function (response) {
                var result = Ext.decode(response.responseText);
                if (result.error) {
@@ -1380,7 +1380,7 @@
 
 function deleteDashboard(name) {
   Ext.Ajax.request({
-    url: "/dashboard/delete/" + name,
+    url: "../dashboard/delete/" + name,
     success: function (response) {
       var result = Ext.decode(response.responseText);
       if (result.error) {
@@ -1503,7 +1503,7 @@
   var dashboardsList;
   var queryField;
   var dashboardsStore = new Ext.data.JsonStore({
-    url: "/dashboard/find/",
+    url: "../dashboard/find/",
     method: 'GET',
     params: {query: "e"},
     fields: ['name'],

=== modified file 'webapp/graphite/account/views.py'
--- webapp/graphite/account/views.py	2010-07-11 01:34:43 +0000
+++ webapp/graphite/account/views.py	2011-04-12 21:48:31 +0000
@@ -24,9 +24,9 @@
   username = request.POST.get('username')
   password = request.POST.get('password')
   if request.method == 'GET':
-    nextPage = request.GET.get('nextPage','/')
+    nextPage = request.GET.get('nextPage','../..')
   else:
-    nextPage = request.POST.get('nextPage','/')
+    nextPage = request.POST.get('nextPage','../..')
   if username and password:
     user = authenticate(username=username,password=password)
     if user is None:
@@ -40,7 +40,7 @@
     return render_to_response("login.html",{'nextPage' : nextPage})
 
 def logoutView(request):
-  nextPage = request.GET.get('nextPage','/')
+  nextPage = request.GET.get('nextPage','../..')
   logout(request)
   return HttpResponseRedirect(nextPage)
 
@@ -55,5 +55,5 @@
   if profile:
     profile.advancedUI = request.POST.get('advancedUI','off') == 'on'
     profile.save()
-  nextPage = request.POST.get('nextPage','/')
+  nextPage = request.POST.get('nextPage','../..')
   return HttpResponseRedirect(nextPage)

=== modified file 'webapp/graphite/render/glyph.py'
--- webapp/graphite/render/glyph.py	2011-04-12 03:07:33 +0000
+++ webapp/graphite/render/glyph.py	2011-04-12 21:48:31 +0000
@@ -69,8 +69,8 @@
   dict(seconds=10,    minorGridUnit=MIN,  minorGridStep=5,  majorGridUnit=MIN,  majorGridStep=20, labelUnit=MIN,  labelStep=20, format="%H:%M", maxInterval=1*DAY),
   dict(seconds=30,    minorGridUnit=MIN,  minorGridStep=10, majorGridUnit=HOUR, majorGridStep=1,  labelUnit=HOUR, labelStep=1,  format="%H:%M", maxInterval=2*DAY),
   dict(seconds=60,    minorGridUnit=MIN,  minorGridStep=30, majorGridUnit=HOUR, majorGridStep=2,  labelUnit=HOUR, labelStep=2,  format="%H:%M", maxInterval=2*DAY),
-  dict(seconds=100,   minorGridUnit=HOUR, minorGridStep=2,  majorGridUnit=HOUR, majorGridStep=4,  labelUnit=HOUR, labelStep=4,  format="%a %l%P", maxInterval=6*DAY),
-  dict(seconds=255,   minorGridUnit=HOUR, minorGridStep=6,  majorGridUnit=HOUR, majorGridStep=12, labelUnit=HOUR, labelStep=12, format="%m/%d %l%P"),
+  dict(seconds=100,   minorGridUnit=HOUR, minorGridStep=2,  majorGridUnit=HOUR, majorGridStep=4,  labelUnit=HOUR, labelStep=4,  format="%a %l%p", maxInterval=6*DAY),
+  dict(seconds=255,   minorGridUnit=HOUR, minorGridStep=6,  majorGridUnit=HOUR, majorGridStep=12, labelUnit=HOUR, labelStep=12, format="%m/%d %l%p"),
   dict(seconds=600,   minorGridUnit=HOUR, minorGridStep=6,  majorGridUnit=DAY,  majorGridStep=1,  labelUnit=DAY,  labelStep=1,  format="%m/%d", maxInterval=14*DAY),
   dict(seconds=600,   minorGridUnit=HOUR, minorGridStep=12, majorGridUnit=DAY,  majorGridStep=1,  labelUnit=DAY,  labelStep=1,  format="%m/%d", maxInterval=365*DAY),
   dict(seconds=2000,  minorGridUnit=DAY,  minorGridStep=1,  majorGridUnit=DAY,  majorGridStep=2,  labelUnit=DAY,  labelStep=2,  format="%m/%d", maxInterval=365*DAY),
@@ -279,9 +279,8 @@
         y += lineHeight
 
   def loadTemplate(self,template):
-    confFile = os.path.join(settings.WEB_DIR,'render','graphTemplates.conf')
     conf = SafeConfigParser()
-    conf.read(confFile)
+    conf.read(settings.GRAPHTEMPLATES_CONF)
     defaults = dict( conf.items('default') )
     if template in conf.sections():
       opts = dict( conf.items(template) )

=== modified file 'webapp/graphite/render/views.py'
--- webapp/graphite/render/views.py	2011-04-09 18:26:57 +0000
+++ webapp/graphite/render/views.py	2011-04-12 21:48:31 +0000
@@ -251,11 +251,11 @@
         connection.timeout = settings.REMOTE_RENDER_CONNECT_TIMEOUT
       # Send the request
       try:
-        connection.request('POST','/render/local/', postData)
+        connection.request('POST','../render/local/', postData)
       except CannotSendRequest:
         connection = HTTPConnectionWithTimeout(server) #retry once
         connection.timeout = settings.REMOTE_RENDER_CONNECT_TIMEOUT
-        conn.request('POST', '/render/local/', postData)
+        conn.request('POST', '../render/local/', postData)
       # Read the response
       response = conn.getresponse()
       assert response.status == 200, "Bad response code %d from %s" % (response.status,server)

=== modified file 'webapp/graphite/settings.py'
--- webapp/graphite/settings.py	2011-03-19 03:23:51 +0000
+++ webapp/graphite/settings.py	2011-04-12 21:48:31 +0000
@@ -89,7 +89,14 @@
 DATABASE_PORT = ''				# Set to empty string for default. Not used with sqlite3.
 
 DASHBOARD_CONF = join(CONF_DIR, 'dashboard.conf')
-
+GRAPHTEMPLATES_CONF = join(CONF_DIR, 'graphTemplates.conf')
+
+ADMINS = ()
+MANAGERS = ADMINS
+
+TEMPLATE_DIRS = (
+  join(WEB_DIR, 'templates'),
+)
 
 #Pull in overrides from local_settings.py
 try:
@@ -98,9 +105,6 @@
   print >> sys.stderr, "Could not import graphite.local_settings, using defaults!"
 
 
-TEMPLATE_DIRS = (
-  join(WEB_DIR, 'templates'),
-)
 
 
 #Django settings below, do not touch!
@@ -111,9 +115,6 @@
 else:
   CACHE_BACKEND = "dummy:///"
 
-ADMINS = ()
-MANAGERS = ADMINS
-
 # Local time zone for this installation. All choices can be found here:
 # http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
 #TIME_ZONE = 'America/Chicago'

=== modified file 'webapp/graphite/templates/browserHeader.html'
--- webapp/graphite/templates/browserHeader.html	2011-04-02 23:03:19 +0000
+++ webapp/graphite/templates/browserHeader.html	2011-04-12 21:48:31 +0000
@@ -68,7 +68,7 @@
 
 <body bgcolor="white">
 
-<img  src="/content/img/graphite_short.png" alt="Graphite" style="border: 0px solid" align='top'/>
+<img  src="../../content/img/graphite_short.png" alt="Graphite" style="border: 0px solid" align='top'/>
 
 <!-- Right side (only works in firefox for some reason) -->
 <!--
@@ -82,19 +82,19 @@
 <table style='display: inline' cellpadding=0 cellspacing=0>
 
  <tr><td style='font-size: smaller;'>
-  <a href="/dashboard/" target="_top">Dashboard UI</a>
+  <a href="../../dashboard/" target="_top">Dashboard UI</a>
  </td></tr>
 
  <tr><td style='font-size: smaller;'>
-  <a href="/cli/" target="_top">Command-Line Interface</a>
+  <a href="../../cli/" target="_top">Command-Line Interface</a>
  </td></tr>
 
  <tr><td style='font-size: smaller;'>
   {% if user.is_authenticated %}
-   Logged in as {{ user.username }}, <a href="/account/logout/" target="_top">logout</a> &nbsp;
-   (<a href="/account/edit/" target="_top">edit profile</a>)
+   Logged in as {{ user.username }}, <a href="../../account/logout/" target="_top">logout</a> &nbsp;
+   (<a href="../../account/edit/" target="_top">edit profile</a>)
   {% else %}
-   <a href="/account/login/" target="_top">Login</a>
+   <a href="../../account/login/" target="_top">Login</a>
   {% endif %}
  </td></tr>
 

=== modified file 'webapp/graphite/templates/composer.html'
--- webapp/graphite/templates/composer.html	2011-04-02 21:36:29 +0000
+++ webapp/graphite/templates/composer.html	2011-04-12 21:48:31 +0000
@@ -17,14 +17,14 @@
 <html>
   <head>
     <title>Graphite Composer</title>
-    <link rel="stylesheet" type="text/css" href="/content/js/ext/resources/css/ext-all.css"/>
+    <link rel="stylesheet" type="text/css" href="../content/js/ext/resources/css/ext-all.css"/>
 
     {% if jsdebug %}
-    <script type="text/javascript" src="/content/js/ext/adapter/ext/ext-base-debug.js"></script>
-    <script type="text/javascript" src="/content/js/ext/ext-all-debug.js"></script>
+    <script type="text/javascript" src="../content/js/ext/adapter/ext/ext-base-debug.js"></script>
+    <script type="text/javascript" src="../content/js/ext/ext-all-debug.js"></script>
     {% else %}
-    <script type="text/javascript" src="/content/js/ext/adapter/ext/ext-base.js"></script>
-    <script type="text/javascript" src="/content/js/ext/ext-all.js"></script>
+    <script type="text/javascript" src="../content/js/ext/adapter/ext/ext-base.js"></script>
+    <script type="text/javascript" src="../content/js/ext/ext-all.js"></script>
     {% endif %}
 
     <script type="text/javascript">
@@ -65,10 +65,10 @@
       }
     </script>
 
-    <script type="text/javascript" src="/content/js/browser.js"></script>
-    <script type="text/javascript" src="/content/js/composer_widgets.js"></script>
-    <script type="text/javascript" src="/content/js/composer.js"></script>
-    <script type="text/javascript" src="/content/js/completer.js"></script>
+    <script type="text/javascript" src="../content/js/browser.js"></script>
+    <script type="text/javascript" src="../content/js/composer_widgets.js"></script>
+    <script type="text/javascript" src="../content/js/composer.js"></script>
+    <script type="text/javascript" src="../content/js/completer.js"></script>
 
     <style type="text/css">
     /* Hack to fix this bug http://extjs.net/forum/showthread.php?s=a570aba1bf2fc67a2287684c5d91c662&t=74230 */
@@ -85,7 +85,7 @@
     </style>
 
     <script type="text/javascript">
-      Ext.BLANK_IMAGE_URL = '/content/js/ext/resources/images/default/s.gif';
+      Ext.BLANK_IMAGE_URL = '../content/js/ext/resources/images/default/s.gif';
 
       var Browser;
       var Composer;

=== modified file 'webapp/graphite/templates/dashboard.html'
--- webapp/graphite/templates/dashboard.html	2011-04-11 07:13:24 +0000
+++ webapp/graphite/templates/dashboard.html	2011-04-12 21:48:31 +0000
@@ -3,8 +3,8 @@
 <html>
   <head>
     <title>Graphite Dashboard</title>
-    <link rel="stylesheet" type="text/css" href="/content/js/ext/resources/css/ext-all.css"/>
-    <link rel="stylesheet" type="text/css" href="/content/css/dashboard.css"/>
+    <link rel="stylesheet" type="text/css" href="../content/js/ext/resources/css/ext-all.css"/>
+    <link rel="stylesheet" type="text/css" href="../content/css/dashboard.css"/>
 
     <script type="text/javascript">
     var schemes = {{schemes_json|safe}};
@@ -13,12 +13,12 @@
     var QUERY_DELAY = 100;
     var NEW_DASHBOARD_REMOVE_GRAPHS = false;
 
-    var RESIZE_ICON   = '/content/js/ext/examples/shared/icons/fam/cog_edit.png';
-    var REMOVE_ICON   = '/content/js/ext/examples/shared/icons/fam/cross.gif';
-    var REFRESH_ICON  = '/content/js/ext/examples/shared/icons/fam/table_refresh.png';
-    var SHARE_ICON    = '/content/js/ext/examples/shared/icons/fam/application_go.png';
-    var CALENDAR_ICON = '/content/js/ext/resources/images/default/shared/calendar.gif';
-    var CLOCK_ICON    = '/content/img/clock_16.png';
+    var RESIZE_ICON   = '../content/js/ext/examples/shared/icons/fam/cog_edit.png';
+    var REMOVE_ICON   = '../content/js/ext/examples/shared/icons/fam/cross.gif';
+    var REFRESH_ICON  = '../content/js/ext/examples/shared/icons/fam/table_refresh.png';
+    var SHARE_ICON    = '../content/js/ext/examples/shared/icons/fam/application_go.png';
+    var CALENDAR_ICON = '../content/js/ext/resources/images/default/shared/calendar.gif';
+    var CLOCK_ICON    = '../content/img/clock_16.png';
 
     {% if initialState %}
     var initialState = {{initialState|safe}};
@@ -38,17 +38,17 @@
     </script>
 
     {% if jsdebug %}
-    <script type="text/javascript" src="/content/js/ext/adapter/ext/ext-base-debug.js"></script>
-    <script type="text/javascript" src="/content/js/ext/ext-all-debug.js"></script>
-    <script type="text/javascript" src="/content/js/dashboard.js"></script>
+    <script type="text/javascript" src="../content/js/ext/adapter/ext/ext-base-debug.js"></script>
+    <script type="text/javascript" src="../content/js/ext/ext-all-debug.js"></script>
+    <script type="text/javascript" src="../content/js/dashboard.js"></script>
     {% else %}
-    <script type="text/javascript" src="/content/js/ext/adapter/ext/ext-base.js"></script>
-    <script type="text/javascript" src="/content/js/ext/ext-all.js"></script>
-    <script type="text/javascript" src="/content/js/dashboard.js"></script>
+    <script type="text/javascript" src="../content/js/ext/adapter/ext/ext-base.js"></script>
+    <script type="text/javascript" src="../content/js/ext/ext-all.js"></script>
+    <script type="text/javascript" src="../content/js/dashboard.js"></script>
     {% endif %}
 
     <script type="text/javascript">
-    Ext.BLANK_IMAGE_URL = '/content/js/ext/resources/images/default/s.gif';
+    Ext.BLANK_IMAGE_URL = '../content/js/ext/resources/images/default/s.gif';
     Ext.QuickTips.init();
     Ext.onReady(initDashboard);
     </script> 

=== modified file 'webapp/graphite/templates/editProfile.html'
--- webapp/graphite/templates/editProfile.html	2010-07-11 01:34:43 +0000
+++ webapp/graphite/templates/editProfile.html	2011-04-12 21:48:31 +0000
@@ -15,7 +15,7 @@
 
 <h2><u>Profile settings for {{profile.user.username}}</u></h2>
 
-<form method='POST' action='/account/update/'>
+<form method='POST' action='../account/update/'>
 {% if nextPage %}
 <input type='hidden' name='nextPage' value='{{nextPage}}'/>
 {% endif %}

=== modified file 'webapp/graphite/templates/login.html'
--- webapp/graphite/templates/login.html	2010-07-11 01:34:43 +0000
+++ webapp/graphite/templates/login.html	2011-04-12 21:48:31 +0000
@@ -28,7 +28,7 @@
 </div>
 {% endif %}
 
-<form method='POST' action='/account/login/'>
+<form method='POST' action='../login/'>
 {% if nextPage %}
 <input type='hidden' name='nextPage' value='{{nextPage}}'/>
 {% endif %}


Follow ups