Skip to content

Instantly share code, notes, and snippets.

@ocharles
Created January 21, 2009 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ocharles/50148 to your computer and use it in GitHub Desktop.
Save ocharles/50148 to your computer and use it in GitHub Desktop.
index c5f53bd..bb97d10 100644
--- a/root/layout.tt
+++ b/root/layout.tt
@@ -1,28 +1,30 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
- "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="expires" content="1" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-
<title>[% title %][% " - " IF title %]MusicBrainz.org</title>
<link rel="stylesheet" type="text/css" href="/static/main.css" />
-
<script type="text/javascript" src="/static/scripts/jquery/jquery-1.3.min.js"></script>
- [% page =
- {
- css = extra_css.split('\s+')
- js = extra_js.split('\s+')
- }
- %]
- [% FOREACH js IN page.js %]
- <script type="text/javascript" src="/static/scripts/[% js %]"></script>
- [% END %]
- [% FOREACH css IN page.css %]
- <link rel="stylesheet" type="text/css" href="/static/styles/extra/[% css %]" />
- [% END %]
+
+ [%- page = {
+ css = extra_css.split('\s+'),
+ js = [
+ 'jquery/jquery.cookie.js',
+ 'sidebar.js'
+ ],
+ };
+ FOR extra IN extra_js.split('\s+'); page.js.push(extra); END -%]
+ [%- FOREACH js IN page.js %]
+ <script type="text/javascript" src="/static/scripts/[% js %]"></script>
+ [%- END %]
+
+ [%- FOREACH css IN page.css %]
+ <link rel="stylesheet" type="text/css" href="/static/styles/extra/[% css %]" />
+ [%- END %]
<link rel="search" type="application/opensearchdescription+xml" title="MusicBrainz: Artist" href="[% c.uri_for('/static/search_plugins/opensearch/musicbrainz_artist.xml') %]" />
<link rel="search" type="application/opensearchdescription+xml" title="MusicBrainz: Label" href="[% c.uri_for('/static/search_plugins/opensearch/musicbrainz_label.xml') %]" />
diff --git a/root/layout/sidebar.tt b/root/layout/sidebar.tt
index ad4f130..246e88a 100644
--- a/root/layout/sidebar.tt
+++ b/root/layout/sidebar.tt
@@ -1,13 +1,30 @@
<div id="sidebar">
- [% INCLUDE "layout/sidebar/sites.tt" WRAPPER "layout/sidebar/section.tt" title="MusicBrainz sites" %]
- [% IF c.user_exists %]
- [% INCLUDE "layout/sidebar/user.tt" WRAPPER "layout/sidebar/section.tt" title=c.user.name link="${c.uri_for('/user/')}" %]
- [% ELSE %]
- [% INCLUDE "layout/sidebar/login.tt" WRAPPER "layout/sidebar/section.tt" title="Not Logged In" link="${c.uri_for('/user/login')}" %]
- [% END %]
- [% INCLUDE "layout/sidebar/search.tt" WRAPPER "layout/sidebar/section.tt" title="Search" %]
- [% INCLUDE "layout/sidebar/top-voters.tt"
- WRAPPER "layout/sidebar/section.tt" title="Top Voters" link=c.uri_for('/statistics/top_editors') %]
- [% INCLUDE "layout/sidebar/stats.tt" WRAPPER "layout/sidebar/section.tt" title="Stats" %]
- [% INCLUDE "layout/sidebar/partners.tt" WRAPPER "layout/sidebar/section.tt" title="Partners" link="http://metabrainz.org/about/supporters.html" %]
+ [% INCLUDE "layout/sidebar/toggle.tt" %]
+ <span class="toggle">
+ [% INCLUDE "layout/sidebar/sites.tt"
+ WRAPPER "layout/sidebar/section.tt" title="MusicBrainz sites" %]
+
+ [% IF c.user_exists %]
+ [% INCLUDE "layout/sidebar/user.tt"
+ WRAPPER "layout/sidebar/section.tt" title=c.user.name link="${c.uri_for('/user/')}" %]
+ [% ELSE %]
+ [% INCLUDE "layout/sidebar/login.tt"
+ WRAPPER "layout/sidebar/section.tt" title="Not Logged In"
+ link="${c.uri_for('/user/login')}" %]
+ [% END %]
+
+ [% INCLUDE "layout/sidebar/search.tt"
+ WRAPPER "layout/sidebar/section.tt" title="Search" %]
+
+ [% INCLUDE "layout/sidebar/top-voters.tt"
+ WRAPPER "layout/sidebar/section.tt" title="Top Voters"
+ link=c.uri_for('/statistics/top_editors') %]
+
+ [% INCLUDE "layout/sidebar/stats.tt"
+ WRAPPER "layout/sidebar/section.tt" title="Stats" %]
+
+ [% INCLUDE "layout/sidebar/partners.tt"
+ WRAPPER "layout/sidebar/section.tt" title="Partners"
+ link="http://metabrainz.org/about/supporters.html" %]
+ </span>
</div>
diff --git a/root/layout/sidebar/search.tt b/root/layout/sidebar/search.tt
index dfd76c9..37ef6c7 100644
--- a/root/layout/sidebar/search.tt
+++ b/root/layout/sidebar/search.tt
@@ -1,8 +1,9 @@
<div id="sidebar_search">
[% WRAPPER "forms/form.tt" action=c.uri_for('/search/simple')
quiet=1 method="get" moderation=undef form=sidebar_search %]
- [% INCLUDE "forms/widget.tt" widget=sidebar_search.field('type') label="Type" %]
- [% INCLUDE "forms/widget.tt" widget=sidebar_search.field('query') label="Query" %]
- [% INCLUDE "forms/submit.tt" label="Search" %]
+ [% INCLUDE "forms/input.tt" widget=sidebar_search.field('type') %]
+ [% INCLUDE "forms/input.tt" widget=sidebar_search.field('query') %]
+
+ <input type="submit" value="Search" class="submit" />
[% END %]
</div>
diff --git a/root/main/index.tt b/root/main/index.tt
index 4ae4bc2..5b21b03 100644
--- a/root/main/index.tt
+++ b/root/main/index.tt
@@ -41,8 +41,7 @@
Unless you want to be testing the latest and greatest MusicBrainz features
you probably want to go to the <a href="http://musicbrainz.org/">
<img src="[% c.uri_for('/static/images/icon/extlink.gif') %]" alt="External Website" />
- musicbrainz.org main
- server</a>.
+ MusicBrainz main server</a>.
</p>
[% END %]
[% END %]
@@ -52,7 +51,7 @@
<p>
If you want to edit the MusicBrainz data, you will need to go to the
<a href="http://musicbrainz.org/">
- <img src="[% c.uri_for('/images/icon/extlink.gif') %]" alt="" width="12" /> MusicBrainz.org main server</a>.
+ <img src="[% c.uri_for('/images/icon/extlink.gif') %]" alt="" width="12" /> MusicBrainz main server</a>.
</p>
[% END %]
[% END %]
diff --git a/root/static/scripts/sidebar.js b/root/static/scripts/sidebar.js
index 5841912..090f7bd 100644
--- a/root/static/scripts/sidebar.js
+++ b/root/static/scripts/sidebar.js
@@ -1,33 +1,54 @@
-/*----------------------------------------------------------------------------\
-| Musicbrainz.org |
-| Copyright (c) 2005 Stefan Kestenholz (keschte) |
-|-----------------------------------------------------------------------------|
-| This software is provided "as is", without warranty of any kind, express or |
-| implied, including but not limited to the warranties of merchantability, |
-| fitness for a particular purpose and noninfringement. In no event shall the |
-| authors or copyright holders be liable for any claim, damages or other |
-| liability, whether in an action of contract, tort or otherwise, arising |
-| from, out of or in connection with the software or the use or other |
-| dealings in the software. |
-| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
-| GPL - The GNU General Public License http://www.gnu.org/licenses/gpl.txt |
-| Permits anyone the right to use and modify the software without limitations |
-| as long as proper credits are given and the original and modified source |
-| code are included. Requires that the final product, software derivate from |
-| the original source or any software utilizing a GPL component, such as |
-| this, is also licensed under the GPL license. |
-| |
-| $Id$
-\----------------------------------------------------------------------------*/
-
-mb.log.scopeStart("Configuring sidebar...");
-mb.log.enter("sidebar.js", "__init");
-if (mb.ui && mb.sidebar) {
- var obj;
- if ((obj = mb.ui.get("sidebar-togglecell")) != null) {
- obj.innerHTML = mb.sidebar.getUI();
- }
- mb.sidebar.init();
+/**************************************************
+ * Adds the show / hide sidebar functionality
+ *************************************************/
+// Store selection in cookie, turn on/off the sidebar
+function flipSidebar() {
+ $(".toggle").toggle();
+ switch($.cookie('sidebar'))
+ {
+ default:
+ case 'on':
+ $.cookie('sidebar', 'off');
+ $('#content').css("margin-left","0px");
+ $('#content').css("margin-top","15px");
+ break;
+ case 'off':
+ $.cookie('sidebar', 'on');
+ $('#content').css("margin-left","140px");
+ $('#content').css("margin-top","0px");
+ }
}
-mb.log.exit();
-
+$(document).ready(function(){
+ // Check that the sidebar is turned on in user
+ // preferences). Does nothing if it is off.
+ if ($('#sidebar').length)
+ $('#id_toggle_target').append(' \
+ <div id="id_hide_toggle" class="toggle"> \
+ <a href="javascript:flipSidebar()"> \
+  Hide Sidebar \
+ </a> \
+ </div> \
+ <div id="id_show_toggle" style="display:none;" class="toggle"> \
+ <a href="javascript:flipSidebar()"> \
+  Show Sidebar \
+ </a> \
+ </div> \
+ ');
+ // Make show / hide selection persistent
+ switch($.cookie('sidebar'))
+ {
+ default:
+ // Set the cookie the first time
+ $.cookie('sidebar', 'on');
+ break;
+ case 'off':
+ // Turn on the sidebar, swap toggle text
+ $(".toggle").toggle();
+ $('#content').css("margin-left","0px");
+ $('#content').css("margin-top","15px");
+ break;
+ // Turn off the sidebar, swap toggle text
+ case 'on':
+ $('#content').css("margin-top","0px");
+ }
+});
diff --git a/root/static/styles/entity.css b/root/static/styles/entity.css
index 0a724de..212776a 100644
--- a/root/static/styles/entity.css
+++ b/root/static/styles/entity.css
@@ -11,6 +11,7 @@
color: #000;
width: 100%;
margin-bottom: 1em;
+ margin-top: 8px;
padding-top: 5px;
}
diff --git a/root/static/styles/layout.css b/root/static/styles/layout.css
index 2d67333..23f7b79 100644
--- a/root/static/styles/layout.css
+++ b/root/static/styles/layout.css
@@ -124,25 +124,27 @@ div.status_ok {
margin-bottom: 20pt;
}
-#sidebar .sidebar-module {
+#sidebar .sidebar-toggle {
border-bottom: 1px solid #000;
- padding: 6pt;
+ padding: 2pt;
}
-#sidebar label {
- font-size: 8pt;
+#sidebar .sidebar-module {
+ border-bottom: 1px solid #000;
+ padding: 6pt;
}
-#sidebar input, #sidebar select {
- width: 50pt;
- background: #eee;
- border: 1px inset;
- font-size: 8pt;
+#sidebar_search { text-align: center; }
+#sidebar_search input,
+#sidebar_search select {
+ font-size: 9pt;
+ margin-top: 1px;
+ margin-left: -2px;
}
-#sidebar .labelRight {
- margin-left: 32pt;
-}
+#sidebar_search select { width: 118px; }
+#sidebar_search input { width: 112px; }
+#sidebar_search .submit { width: auto; }
#sidebar img {
margin: auto;
@@ -201,6 +203,11 @@ div.status_ok {
padding-left: 5pt;
}
+#sidebar .sidebar-toggle {
+ border-bottom: 1px solid #000;
+ padding: 2pt;
+}
+
/*
* Content
*/
@@ -267,22 +274,6 @@ table.details th {
/* Nested details tables look dumb */
table.details table.details th { font-weight: normal; }
-#sidebar_search label {
- float: left;
- width: 30pt;
- margin-right: 2pt;
- text-align: right;
-}
-
-#sidebar_search input,
-#sidebar_search select {
- width: 50pt;
-}
-
-#sidebar_search .submit {
- width: auto;
-}
-
.paginator ul {
margin: 0;
}
@@ -464,4 +455,4 @@ table.browse {
table.browse td {
text-align: center;
padding: 0pt 4pt;
-}
\ No newline at end of file
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment