Module: check_mk
Branch: master
Commit: eb9d5fec38f1b49e408913026050065495c28153
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=eb9d5fec38f1b4…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Aug 19 20:49:29 2011 +0200
Bookmarks snapin: save relative URLs whenever possible
---
.bugs/24 | 10 +++++++---
ChangeLog | 1 +
web/plugins/sidebar/shipped.py | 10 ++++++++++
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/.bugs/24 b/.bugs/24
index 621161e..b24a332 100644
--- a/.bugs/24
+++ b/.bugs/24
@@ -1,12 +1,16 @@
Title: Multisite Bookmarks: relative (minimale) URLs speichern
Component: multisite
+State: done
+Class: nastiness
+Date: 2010-12-21 16:28:32
Benefit: 1
-State: open
Cost: 1
-Date: 2010-12-21 16:28:32
-Class: nastiness
+Fun: 0
Das Snapin speichert immer absolute URLs mit Hostnamen.
Das ist aber doof, wenn man die Bookmarksdatei auf einen anderen Host kopiert
oder mal mit IP-Adresse, mal mit Namen auf Nagios zugreift. Lösung: Beim Speichern
der Bookmarks den gemeinsamen Pfad vorne wegschneiden.
+
+2011-08-19 20:50:03: changed state open -> done
+Gemeinsamer Teil wird vorne weggesäbelt.
diff --git a/ChangeLog b/ChangeLog
index 9c816f9..8a73476 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,7 @@
Multisite:
* FIX: reschedule now works for host names containing spaces
+ * Bookmarks snapin: save relative URLs whenever possible
1.1.11i2:
Core, Setup, etc.:
diff --git a/web/plugins/sidebar/shipped.py b/web/plugins/sidebar/shipped.py
index 300ae22..233ada5 100644
--- a/web/plugins/sidebar/shipped.py
+++ b/web/plugins/sidebar/shipped.py
@@ -922,6 +922,16 @@ def ajax_add_bookmark():
href = html.var("href")
if title and href:
bookmarks = load_bookmarks()
+ # We try to remove
http://hostname/some/path/check_mk from the
+ # URI. That keeps the configuration files (bookmarks) portable.
+ # Problem here: We have not access to our own URL, only to the
+ # path part. The trick: we use the Referrer-field from our
+ # request. That points to the sidebar.
+ referer = html.req.headers_in.get("Referer")
+ if referer:
+ while '/' in referer and referer.split('/')[0] ==
href.split('/')[0]:
+ referer = referer.split('/', 1)[1]
+ href = href.split('/', 1)[1]
bookmarks.append((title, href))
save_bookmarks(bookmarks)
render_bookmarks()