forked from Shopify/dashing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
251 lines (208 loc) · 13.9 KB
/
Copy pathindex.html
File metadata and controls
251 lines (208 loc) · 13.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link href='http://fonts.googleapis.com/css?family=Coustard|Cutive|Quando' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/font-awesome.css">
<link rel="stylesheet" href="style.css">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-82702-43']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div role="main" id="container">
<nav id="main-navigation">
<ul class="clearfix">
<li><a href="#overview">Introduction</a></li>
<li><a href="http://dashingdemo.herokuapp.com/sample" target="_blank">Demo</a></li>
<li><a href="#setup">Getting Started</a></li>
<li><a href="#widgets">Example Setup</a></li>
<li><a href="#data">API</a></li>
<li><a href="#license">License</a></li>
<li><a href="https://github.com/Shopify/dashing/issues" target="_blank">Issues</a></li>
</ul>
</nav>
<section id="heading" class="clearfix">
<div id="logo-heading">
<h1>Dashing</h1>
<h2>The exceptionally handsome dashboard framework.</h2>
</div>
<div id="logo-bowtie">
<img src="images/bowtie.png"/>
</div>
<div id="actions">
<a class="button" href="https://github.com/Shopify/dashing" target="_blank"><i class="icon-github"></i> View on Github</a>
<a class="button" href="https://github.com/Shopify/dashing/zipball/master"><i class="icon-download"></i> Download ZIP</a>
</div>
<div id="actions-github">
<iframe src="http://ghbtns.com/github-btn.html?user=shopify&repo=dashing&type=watch&count=false"
allowtransparency="true" frameborder="0" scrolling="0" width="51px" height="20px"></iframe>
<iframe src="http://ghbtns.com/github-btn.html?user=shopify&repo=dashing&type=fork&count=false"
allowtransparency="true" frameborder="0" scrolling="0" width="53px" height="20px"></iframe>
<iframe src="http://ghbtns.com/github-btn.html?user=shopify&type=follow&count=true"
allowtransparency="true" frameborder="0" scrolling="0" width="165px" height="20px"></iframe>
</div>
</section>
<section class="section-box" id="overview">
<h3 class="section-title">Introduction</h3>
<div class="section-content">
<p>Dashing is a Sinatra based framework that lets you build beautiful dashboards.</p>
<p>Check out a demo over <a href="http://dashingdemo.herokuapp.com/sample" target="_blank">here</a>. <a href="http://dashingdemo.herokuapp.com/sampletv" target="_blank">Here's another one</a>, optimized for 1080p screens.</p>
<p><strong>Key features:</strong>
<ul>
<li>Use premade widgets, or fully create your own with scss, html, and coffeescript.</li>
<li>Widgets harness the power of data bindings to keep things DRY and simple. Powered by <a href="http://batmanjs.org/" target="_blank">batman.js</a>.</li>
<li>Use the API to push data to your dashboards, or make use of a simple ruby DSL for fetching data.</li>
<li>Drag & Drop interface for re-arranging your widgets.</li>
<li><a href="https://github.com/Shopify/dashing/wiki/How-to%3A-Deploy-to-Heroku" target="_blank">Host your dashboards on Heroku</a> in less than 30 seconds.</li>
</ul>
</p>
<p>This project was created at <a href="http://shopify.com" target="_blank">Shopify</a> for displaying custom dashboards on TVs around the office.</p>
</div>
</section>
<section class="section-box" id="setup">
<h3 class="section-title">Getting Started</h3>
<div class="section-content">
<ol>
<li>
<p> Install the gem from the command line. Make sure you have Ruby 1.9</p>
<p><code>$ gem install dashing</code></p>
</li>
<li>
<p> Generate a new project</p>
<p><code>$ dashing new sweet_dashboard_project</code></p>
</li>
<li>
<p> Change your directory to <code>sweet_dashboard_project</code> and bundle gems</p>
<p><code>$ bundle</code></p>
</li>
<li>
<p>Start the server!</p>
<p><code>$ dashing start</code></p>
</li>
<li>
<p> Point your browser at <a href="http://localhost:3030">localhost:3030</a> and have fun!</p>
</li>
</ol>
<hr/>
<p>Every new Dashing project comes with sample widgets & sample dashboards for you to explore. The directory is setup as follows:</p>
<ul>
<li><strong>Assets</strong> — All your images, fonts, and js/coffeescript libraries. <i>Uses <a href="https://github.com/sstephenson/sprockets" target="_blank">Sprockets</a></i></li>
<li><strong>Dashboards</strong> — One .erb file for each dashboard that contains the layout for the widgets.</li>
<li><strong>Jobs</strong> — Your ruby jobs for fetching data (e.g for calling third party APIs like twitter).</li>
<li><strong>Lib</strong> — Optional ruby files to help out your jobs.</li>
<li><strong>Public</strong> — Static files that you want to serve. A good place for a favicon or a custom 404 page.</li>
<li><strong>Widgets</strong> — All the html/css/coffee for individual widgets.</li>
</ul>
<p>Run <code>dashing</code> from command line to find out what command line tools are available to you.</p>
</div>
</section>
<section class="section-box" id="widgets">
<h3 class="section-title">Example Dashboard</h3>
<div class="section-content">
Here's a sample dashboard with 2 widgets. With a name of <code>sample.erb</code>, it becomes accessible at <code>/sample</code>.
<br/>
<br/>
<script src="https://gist.github.com/3977816.js"></script>
<p>Each widget is represented by a <code>div</code> element needing <code>data-id</code> and <code>data-view</code> attributes. The wrapping <code><li></code>tags are used for <a href="#positioning">layout</a>.</p>
<p><code>data-id</code>: Sets the <strong>widget ID</strong> which will be used when pushing data to the widget. Two widgets can have the same widget id, allowing you to have the same widget in multiple dashboards. <a href="#data">Push data</a> to that id, and each instance will be updated.</p>
<p><code>data-view</code>: Specifies the type of widget that will be used.</p>
<p>Both these widgets are of the same type: <code>Number</code>. However, using different <code>data-</code> attributes lets you customize them. You can use any arbitrary attribute you want — each one will be available for you within the widget logic.</p>
<div class="widgets"><img src="images/widget1.png" alt="Widget"> <img src="images/widget2.png" alt="Widget"></div>
<h4>Anatomy of a widget</h4>
<ul>
<li>an HTML file used for layout and bindings</li>
<li>a SCSS file for styles</li>
<li>a coffeescript file which allows you to handle incoming data & functionality</li>
</ul>
<h5><code>Number</code> widget's HTML:</h5>
<script src="https://gist.github.com/3978209.js?file=number.html"></script>
<p>Widgets use <a href="http://batmanjs.org/docs/batman.html#batman-view-bindings-how-to-use-bindings" target="_blank">batman bindings</a> in order to update their contents. Whenever the data changes, the DOM will automatically reflect the changes.</p>
<p>You may notice the piping '|' characters in some of the <code>data-bind</code>'s above. These are <a href="http://batmanjs.org/docs/batman.html#batman-view-bindings-keypath-filters" target="_blank">Batman Filters</a>, and let you easily format the representation of data.
<h5><code>Number</code> widget's Coffeescript:</h5>
<script src="https://gist.github.com/3978186.js?file=number.coffee"></script>
<p>By default, whenever a widget receives JSON data, it mixes in the received data onto itself. This means that if you pass in data with a <code>title</code> attribute, the widget's <code>title</code> variable will change, and so will all DOM elements bound to it. No need to handle that yourself.</p>
<h4 id="positioning">Laying out the widgets</h4>
<p>Dashing uses <a href="http://gridster.net/" target="_blank">gridster.js</a> to create a layout for your widgets. Each widget is part of an unordered list. The <code><li></code> element for a widget contains:</p>
<ul>
<li><code>data-row</code> : What row the widget is on.</li>
<li><code>data-col</code> : What column the widget is on</li>
<li><code>data-sizex</code> : Integer size for the width of a widget</li>
<li><code>data-sizey</code> : Integer size for the height of a widget</li>
</ul>
<p>For both <code>data-row</code> and <code>data-col</code>, you can leave them as 1, and gridster will automatically position your widgets.</p>
<p>If you want to customize the layout easily, simply navigate to your running dashboard, and drag the widgets with your mouse. You will be prompted to save the layout when you're finished. Follow the on-screen instructions.</p>
<p>For <code>data-sizex</code> and <code>data-sizey</code>, these are multiples of the widget dimensions you can configure in <code>application.coffee</code></p>
<script src="https://gist.github.com/3978786.js?file=application.coffee"></script>
</div>
</section>
<section class="section-box" id="data">
<h3 class="section-title">Getting Data Into Your Widgets</h3>
<div class="section-content">
<p>Providing data to widgets is easy. You specify which widget you want using a widget id, and then pass in the JSON data. There are two ways to do this:</p>
<h4>Jobs</h4>
<p>Dashing uses <a href="http://rufus.rubyforge.org/rufus-scheduler/" target="_blank">rufus-scheduler</a> to schedule jobs. You can make a new job with <code>dashing generate job sample_job</code>, which will create a file in the jobs directory called <code>sample_job.rb</code>.</p>
<h6>Example</h6>
<script src="https://gist.github.com/3978821.js?file=sample_job.rb"></script>
<p>This job will run every minute, and will send a random number to ALL widgets that have <code>data-id</code> set to 'karma'.<p>
<p>You send data using the following method:</p>
<code>send_event(widget_id, json_formatted_data)</code>
<br/>
<p>Jobs are where you put stuff such as fetching metrics from a database, or calling a third party API like Twitter. Since the data fetch is happening in only one place, it means that all instances of widgets are in sync. <a href="http://www.html5rocks.com/en/tutorials/eventsource/basics/" target="_blank">Server Sent Events</a> are used in order to stream data to the dashboards. </p>
<h4>API</h4>
<p>You can also push data directly to your dashboard! Post the data you want in json to <code>/widgets/widget_id</code>.
For security, you will also have to include your auth_token (which can be found in <code>config.ru</code>).</p>
<h6>Example</h6>
<script src="https://gist.github.com/3978832.js?file=push.sh"></script>
<p>or</p>
<script src="https://gist.github.com/3981096.js?file=push.rb"></script>
</div>
</section>
<section class="section-box" id="compatibility">
<h3 class="section-title">Additional Resources</h3>
<div class="section-content">
<p>Check out the <a href="https://github.com/Shopify/dashing/wiki" target="_blank">wiki</a> for interesting tips such as hosting on Heroku, or adding authentication.</p>
<p>Be sure to look at <a href="https://github.com/Shopify/dashing/wiki/Additional-Widgets" target="_blank">the list of third party widgets.</a></p>
</div>
</section>
<section class="section-box" id="compatibility">
<h3 class="section-title">Browser Compatibility</h3>
<div class="section-content">
<p>Tested in Chrome, Safari 6+, and Firefox 15+. </p>
<p>Does <strong>not</strong> work in Internet Explorer because it relies on <a href="http://www.html5rocks.com/en/tutorials/eventsource/basics/" target="_blank">Server Sent Events.</a></p>
</div>
</section>
<section class="section-box" id="compatibility">
<h3 class="section-title">Contributors</h3>
<div class="section-content">
<ul>
<li><a href="http://twitter.com/pushmatrix" target="_blank">Daniel Beauchamp</a></li>
<li><a href="http://twitter.com/serenangai" target="_blank">Serena Ngai </a></li>
<li><a href="http://twitter.com/tahnok" target="_blank">Wesley Ellis </a></li>
</div>
<p>All contributions are more than welcome; <a href="https://github.com/Shopify/dashing/wiki/Additional-Widgets" target="_blank">especially new widgets!</a></p>
</section>
<section class="section-box" id="license">
<h3 class="section-title">License</h3>
<div class="section-content">
<p>Dashing is released under the <a href="https://github.com/Shopify/dashing/blob/master/MIT-LICENSE" target="_blank">MIT license</a></p>
</div>
</section>
<small>Copyright 2013 - Shopify</small>
</div>
<footer>
</footer>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
</body>
</html>