Revision 8705
Added by Lauren Walker almost 11 years ago
docs/user/metacat/source/themes.rst | ||
---|---|---|
16 | 16 |
|
17 | 17 |
Quick Start Using the Default Theme |
18 | 18 |
----------------------------------- |
19 |
To use the default theme, shown in the figure above, follow these steps for a quick start with MetacatUI:
|
|
19 |
The default theme can be used out-of-box. To make simple edits such as change the logo in the header or footer, add links to the navigation, etc., we will need to create a new theme, make our changes to the header and footer HTML templates, but borrow all other templates from the default theme so we don't have to create everything from scratch.
|
|
20 | 20 |
|
21 |
1. Copy the ``js/themes/default`` directory and rename it to your organization's name or choose a unique theme name.
|
|
21 |
1. **Create a new theme:** Duplicate the ``js/themes/default`` directory and rename it to a unique theme name with no spaces.
|
|
22 | 22 |
|
23 |
2. In the ``js/themes/<yourtheme>/config.js`` file, change the theme name on line 1, ``default``, to your chosen new theme name.
|
|
23 |
2. **Add your logo:** In the ``js/themes/<yourtheme>/img`` directory, add the following image files:
|
|
24 | 24 |
|
25 |
3. In the ``js/themes/<yourtheme>/img`` directory, add the following image files: |
|
26 |
|
|
27 | 25 |
* Your organization's logo |
28 | 26 |
* Any supporter or donor logos to use in the footer |
29 | 27 |
|
30 |
4. Create a ``templates`` directory in ``js/themes/<yourtheme>`` and copy the following files from ``js/templates`` into
|
|
28 |
3. **Customize the header and footer:** Create a ``templates`` directory in ``js/themes/<yourtheme>`` and copy the following files from ``js/templates`` into
|
|
31 | 29 |
that new directory: |
32 | 30 |
|
33 | 31 |
* footer.html |
34 | 32 |
* navbar.html |
35 | 33 |
|
36 |
5. Open the ``js/themes/<yourtheme>/templates/footer.html`` file and change the footer logo image paths and the link paths to direct to
|
|
34 |
3a. Open the ``js/themes/<yourtheme>/templates/footer.html`` file and change the footer logo image paths and the link paths to direct to
|
|
37 | 35 |
your new footer images and their corresponding web addresses. For example, |
38 | 36 |
|
39 | 37 |
:: |
40 | 38 |
|
41 |
<a href="http://nceas.ucsb.edu" target="_blank"><img alt="NCEAS" src="./js/themes/themename/img/nceas-logo-white.png"></a> |
|
39 |
<a href="http://nceas.ucsb.edu" target="_blank"> |
|
40 |
<img alt="NCEAS" src="./js/themes/yourtheme/img/nceas-logo-white.png"> |
|
41 |
</a> |
|
42 | 42 |
|
43 |
You can also add or modify the "Help" email addresses displayed in the footer.
|
|
43 |
You can add or modify any of the HTML in the footer; we are using the logo only as a simple demonstration.
|
|
44 | 44 |
|
45 |
6. Open the ``js/themes/<yourtheme>/templates/navbar.html`` file and replace the Metacat logo file with your organization's logo file.
|
|
45 |
3b. Similarly, open the ``js/themes/<yourtheme>/templates/navbar.html`` file and replace the Metacat logo file with your organization's logo file. You can also add more links to this header navigation.
|
|
46 | 46 |
|
47 |
4. **Create your theme map:** By default, Metacat will use the default theme templates unless you specifically tell Metacat to override these with the template files in your custom theme. |
|
48 |
In the ``js/themes/<yourtheme>/config.js`` file, change the theme name on line 1, ``default``, to your chosen new theme name. |
|
49 |
In the ``themeMap``, add a new line for every template you have edited and added to your new theme. An example for the footer.html and navbar.html files is below. |
|
47 | 50 |
|
48 |
7. Open ``index.html``. Edit the following line to reflect your theme name (``data-theme``) and your Metacat |
|
49 |
context (``data-metacat-context``): |
|
51 |
:: |
|
52 |
|
|
53 |
var theme = theme || "default"; |
|
54 |
var themeMap = |
|
55 |
{ |
|
56 |
'*': { |
|
57 |
// example overrides are provided here |
|
58 |
'templates/navbar.html' : 'themes/' + theme + '/templates/navbar.html', |
|
59 |
'templates/footer.html' : 'themes/' + theme + '/templates/footer.html' |
|
60 |
} |
|
61 |
}; |
|
50 | 62 |
|
63 |
5. Repeat step 3-4 as necessary for any other template files you edit. |
|
64 |
|
|
65 |
6. **Specify your theme and metacat context** Open ``index.html``. Edit the following line to specify your theme name (attribute ``data-theme``) and your Metacat |
|
66 |
context (attribute ``data-metacat-context``): |
|
67 |
|
|
51 | 68 |
:: |
52 | 69 |
|
53 | 70 |
<script data-theme="default" data-metacat-context="metacat" id="loader" type="text/javascript" src="loader.js"></script> |
54 | 71 |
|
55 | 72 |
|
73 |
|
|
56 | 74 |
Creating a Custom Theme |
57 | 75 |
----------------------- |
58 | 76 |
All themes share the same CSS, HTML, JavaScript and image files. Any of these files can be customized by creating |
59 |
a new theme. By creating a new theme, these shared default files |
|
60 |
are overridden by your custom theme files. |
|
77 |
a new theme and telling Metacat to override the default files with the ones in your custom theme. |
|
61 | 78 |
|
62 |
1. Copy an existing theme directory structure, found in ``js/themes``, and rename that directory after your new theme. |
|
79 |
1. **Create a new theme:** Copy an existing theme directory structure, found in ``js/themes``, and rename that directory after your new theme.
|
|
63 | 80 |
Notice that each theme directory looks something like this: |
64 | 81 |
|
65 | 82 |
:: |
... | ... | |
69 | 86 |
routers/ |
70 | 87 |
templates/ |
71 | 88 |
config.js |
72 |
|
|
73 | 89 |
|
74 |
2. Only the ``config.js`` file is required for your theme - overrides are added to this configuration file as needed. |
|
75 |
|
|
76 |
3. Add a CSS file to your theme by creating a CSS file in the ``js/themes/<yourtheme>/css/`` directory |
|
90 |
2. **Style your theme** Add a CSS file to your theme by creating a CSS file in the ``js/themes/<yourtheme>/css/`` directory |
|
77 | 91 |
named ``metacatui.css`` |
78 | 92 |
|
79 |
4. Add your custom images to the ``js/themes/<yourtheme>/img`` directory.
|
|
93 |
3. **Add images** Add your custom images to the ``js/themes/<yourtheme>/img`` directory.
|
|
80 | 94 |
|
81 |
5. Add HTML templates to the ``js/themes/<yourtheme>/templates`` directory.
|
|
95 |
4. **Edit templates** Add HTML templates to the ``js/themes/<yourtheme>/templates`` directory.
|
|
82 | 96 |
|
83 |
6. Open the ``js/themes/<yourtheme>/config.js`` file. In here you will define your theme and themeMap.
|
|
97 |
5. **Create your theme map** Open the ``js/themes/<yourtheme>/config.js`` file. In here you will define your theme and themeMap. By default, Metacat will use the default theme templates unless you specifically tell Metacat to override these with the template files in your custom theme.
|
|
84 | 98 |
|
85 | 99 |
:: |
86 | 100 |
|
... | ... | |
94 | 108 |
} |
95 | 109 |
}; |
96 | 110 |
|
97 |
Give your theme a name on the first line. Then follow the commented out examples in ``themeMap`` to
|
|
98 |
explicitly tell MetacatUI which default shared files should be overridden with your custom theme
|
|
111 |
Change the theme name on line 1, ``default``, to your chosen new theme name. Then follow the commented out examples in ``themeMap`` to
|
|
112 |
explicitly tell Metacat which default shared files should be overridden with your custom theme |
|
99 | 113 |
files. The pattern is: |
100 | 114 |
|
101 | 115 |
``path/originalFile.html : 'themes/' + theme + '/path/newFile.html'`` |
102 | 116 |
|
103 |
**Note: You do not have to override the CSS or image files.**
|
|
117 |
*Note: You do not have to override the CSS or image files.*
|
|
104 | 118 |
|
105 |
7. Open ``index.html``. Edit the following line to reflect your theme name (``data-theme``) and your Metacat
|
|
106 |
context (``data-metacat-context``): |
|
119 |
7. **Specify your theme and metacat context** Open ``index.html``. Edit the following line to specify your theme name (attribute ``data-theme``) and your Metacat
|
|
120 |
context (attribute ``data-metacat-context``):
|
|
107 | 121 |
|
108 | 122 |
:: |
109 | 123 |
|
... | ... | |
119 | 133 |
<img src="" class="bg" id="bg_image" data-image-count="9" /> |
120 | 134 |
|
121 | 135 |
Change the ``data-image-count`` attribute to the number of images you would like to cycle through in your custom |
122 |
theme. To have the same background image on all views, change this value to 1. |
|
136 |
theme. To have the same background image on all views, change this value to 1. To not use the background image at all, simply remove this ``<img>`` element.
|
|
123 | 137 |
|
124 |
Store the background image files in ``img/backgrounds``. Keep the naming convention of ``bg1.jpg``, ``bg2.jpg``, etc.
|
|
125 |
with all numbers from 1 to your chosen total present (i.e. do not skip any numbers, such as ``bg1.jpg``, ``bg3.jpg`` ...)
|
|
138 |
Store your custom background image files in ``js/themes/<yourtheme>/img/backgrounds``. Keep the naming convention of ``bg1.jpg``, ``bg2.jpg``, etc., making sure
|
|
139 |
that all numbers from 1 to your specified total (``data-image-count``) are included. (i.e. do not skip any numbers, such as ``bg1.jpg``, ``bg3.jpg`` ...)
|
|
126 | 140 |
|
127 | 141 |
|
128 | 142 |
Advanced options for custom themes |
129 | 143 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
130 |
Advanced users can choose to override the JavaScript files for even more customization of MetcatUI. |
|
144 |
Advanced users can choose to override the JavaScript files for even more customization of MetacatUI.
|
|
131 | 145 |
|
132 | 146 |
|
133 | 147 |
The ``router.js`` file can be modified to render different views based on the URL. For example, |
... | ... | |
140 | 154 |
// ---------------- |
141 | 155 |
var UIRouter = Backbone.Router.extend({ |
142 | 156 |
routes: { |
143 |
'' : 'routeToData', // default is data search page
|
|
144 |
'about' : 'renderAbout', // about page
|
|
145 |
'about(/:anchorId)' : 'renderAbout', // about page anchors
|
|
146 |
'plans' : 'renderPlans', // plans page
|
|
147 |
'tools(/:anchorId)' : 'renderTools', // tools page
|
|
148 |
'data(/search/:searchTerm)(/page/:page)' : 'renderData', // data search page
|
|
149 |
'view/*pid' : 'renderMetadata', // metadata page
|
|
150 |
'external(/*url)' : 'renderExternal', // renders the content of the given url in our UI
|
|
151 |
'logout' : 'logout', // logout the user
|
|
152 |
'signup' : 'renderLdap', // use ldapweb for registration
|
|
153 |
'account(/:stage)' : 'renderLdap', // use ldapweb for different stages
|
|
154 |
'share' : 'renderRegistry' // registry page
|
|
157 |
'' : 'routeToData', // route ROOT to data
|
|
158 |
'about' : 'renderAbout', |
|
159 |
'about(/:anchorId)' : 'renderAbout', |
|
160 |
'plans' : 'renderPlans', |
|
161 |
'tools(/:anchorId)' : 'renderTools', |
|
162 |
'data(/search/:searchTerm)(/page/:page)' : 'renderData', |
|
163 |
'view/*pid' : 'renderMetadata', |
|
164 |
'external(/*url)' : 'renderExternal', |
|
165 |
'logout' : 'logout', |
|
166 |
'signup' : 'renderLdap', |
|
167 |
'account(/:stage)' : 'renderLdap', |
|
168 |
'share' : 'renderRegistry' |
|
155 | 169 |
}, |
156 | 170 |
|
157 | 171 |
In this example, the index path, ``''``, was changed from |
... | ... | |
165 | 179 |
this.navigate("data", {trigger: true}); |
166 | 180 |
}, |
167 | 181 |
|
168 |
**Note: Remember to include any views or router.js in your list of overrides in js/themes/<yourtheme>/config.js
|
|
182 |
**Note: Remember to include any views or routers in your list of overrides in js/themes/<yourtheme>/config.js |
|
169 | 183 |
for each file you modify** |
170 | 184 |
|
171 | 185 |
|
Also available in: Unified diff
Edited the docs to incude more details about creating a custom theme