Skip to content

Commit dadfba8

Browse files
committed
Merge pull request #4 from Klortho/master
Load assets from a relative path instead of a absolute, instructions in Readme, added execjs and therubyracer to Gemfile
2 parents b83dbb8 + 919ad7b commit dadfba8

9 files changed

Lines changed: 53 additions & 43 deletions

File tree

Gemfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ gem 'sass'
88
gem 'coffee-script'
99
gem 'haml'
1010
gem 'sinatra'
11-
gem 'crack'
11+
gem 'crack'
12+
13+
gem 'execjs'
14+
gem 'therubyracer'

README.md

100644100755
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ The GitHub repo of the official docs site will be cloned/updated.
4141
Point your browser to localhost:9292 and there you have the latest jQuery documentation with jQAPI
4242
wrapped around.
4343

44+
### Generate static files
45+
46+
thor deploy:generate
47+
48+
Generates index.html, bundle.js, bundle.css, etc., so that the documentation can be
49+
viewed from a set of static files.
50+
4451
## Known Issues - Work in progress
4552
- check if method is deprecated, if so indicate it
4653
- jQuery() documentation is broken

app/assets/javascripts/categories.js.coffee

100644100755
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class jqapi.Categories
22
constructor: ->
33
@el = $ '#categories' # parent ul element
44
self = @
5-
5+
66
jqapi.events.on 'navigation:done', => # call when everything is loaded and generated
77
@hideLoader() # hide the loader
88

@@ -14,8 +14,8 @@ class jqapi.Categories
1414

1515
jqapi.events.on 'categories:toggle', (e, catEl) => # on request to toggle a category
1616
@toggleCategory catEl # toggle the category content
17-
18-
$.getJSON '/docs/index.json', (data) => # load the index json data with all categories and entries
17+
18+
$.getJSON 'docs/index.json', (data) => # load the index json data with all categories and entries
1919
@buildNavigation data # and build from the object when loaded
2020
jqapi.events.trigger 'index:done', [data] # let the app know that the index is loaded
2121

@@ -58,7 +58,7 @@ class jqapi.Categories
5858
if subcats and subcats.length # are there any sub categories?
5959
for subcat in subcats # for each sub category
6060
listEl = $ templates.categoryItem('sub', subcat.name) # get template for category
61-
61+
6262
if subcat.entries.length # if the sub category has entries
6363
listEl.append @buildEntriesList(subcat.entries) # build and append the entries
6464
listEl.appendTo el # append entries list to category

app/assets/javascripts/entry.js.coffee

100644100755
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ class jqapi.Entry
1919
document.title = "#{entry.title} - jQAPI" # set a new title
2020

2121
loadContent: (slug) ->
22-
$.getJSON "/docs/entries/#{slug}.json", (data) => # fetch from json file
22+
$.getJSON "docs/entries/#{slug}.json", (data) => # fetch from json file
2323
data.slug = slug
2424
@parseEntry data # parse what was received
2525
jqapi.events.trigger 'entry:done', [data] # let the app know that a new entry is loaded
2626
@el.removeClass 'loading'
2727

2828
parseEntry: (entry) ->
2929
el = $ templates.entry(entry) # generate element from template
30-
30+
3131
#@insertCategories entry, el # generate and insert categories
3232
@insertEntries entry, el # generate entries and insert
3333

@@ -36,7 +36,7 @@ class jqapi.Entry
3636
@highlightCode()
3737
@adjustCodeHeight() # set equal heights for the code boxes
3838
@fixLinks()
39-
39+
4040
insertCategories: (entry, el) ->
4141
catsEl = $('#categories', el) # cache categories list
4242

@@ -143,7 +143,7 @@ class jqapi.Entry
143143
playH -= cssEl.height() if cssEl.length
144144
playH += 100 if playH < 100
145145
playH = 130 if playH < 0
146-
146+
147147
sandboxEl.children('.play').height playH
148148

149149
fixLinks: ->
@@ -161,9 +161,9 @@ class jqapi.Entry
161161
if hrefArr[2] is 'api.jquery.com'
162162
href = hrefArr[hrefArr.length - 1]
163163
href = hrefArr[hrefArr.length - 2] if href.length is 0
164-
164+
165165
el.attr 'href', "#p=#{href}"
166-
166+
167167
buildLiveExamples: ->
168168
sandboxEls = $('.sandbox', @el)
169169

@@ -178,5 +178,5 @@ class jqapi.Entry
178178
js : el.find('.js pre').text()
179179
css : el.find('.css pre').text()
180180
external:
181-
js : ['/assets/jquery.js']
181+
js : ['assets/jquery.js']
182182
el : $('.play', sandboxEl).text('')

app/assets/stylesheets/categories.css.sass

100644100755
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
.loader
33
text-align: center
44
padding-top: 20px
5-
5+
66
.top-cat
77
.top-cat-name
88
display: block
9-
background: url('/assets/arrow.png') no-repeat #ddd
9+
background: url('arrow.png') no-repeat #ddd
1010
border-bottom: 1px solid #ccc
1111
padding: 7px 0 7px 25px
1212
cursor: pointer
13-
13+
1414
.top-cat-name:hover, &.hover .top-cat-name
15-
background: url('/assets/arrow.png') 0 -27px no-repeat #cecece
15+
background: url('arrow.png') 0 -27px no-repeat #cecece
1616
border-bottom: 1px solid rgba(0, 0, 0, 0.1)
1717
box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.2)
1818
color: #111
19-
19+
2020
.sub-cats
2121
display: none
2222

@@ -28,14 +28,14 @@
2828
border-bottom: 1px dotted #ddd
2929
padding: 7px 0 7px 25px
3030
cursor: pointer
31-
31+
3232
.sub-cat-name:hover, &.hover .sub-cat-name
3333
background: #dedede
3434
border-bottom: 1px solid #d3d3d3
3535

3636
.open, .open.hover
3737
.top-cat-name, .top-cat-name:hover
38-
background: url('/assets/arrow.png') 0 -54px no-repeat #cecece
38+
background: url('arrow.png') 0 -54px no-repeat #cecece
3939
border-bottom: 1px solid rgba(0, 0, 0, 0.1)
4040
box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.2)
4141
color: #111

app/assets/stylesheets/entry.css.sass

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
height: 400px
55

66
&.loading
7-
background: url('/assets/loader.gif') no-repeat center center
8-
7+
background: url('loader.gif') no-repeat center center
8+
99
#entry-wrapper
1010
padding: 20px 30px
1111

app/assets/stylesheets/main.css.sass

100644100755
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
html
22
font-size: 16px
3-
3+
44
body
55
font-size: 62.5%
66
font-family: "Helvetica Neue", Arial, sans-serif
@@ -78,7 +78,7 @@ body
7878
display: block
7979
width: 264px
8080
height: 61px
81-
background: url('/assets/hashrocket.png') no-repeat
81+
background: url('hashrocket.png') no-repeat
8282
text-indent: -30000px
8383

8484
#credits
@@ -120,7 +120,7 @@ body
120120

121121
#changelog
122122
position: relative
123-
123+
124124
a
125125
position: absolute
126126
top: 55px
@@ -164,16 +164,16 @@ body
164164

165165
#zip
166166
a
167-
background: url('/assets/download_zip.png') top center no-repeat
167+
background: url('download_zip.png') top center no-repeat
168168

169169
#air
170170
a
171-
background: url('/assets/download_air.png') top center no-repeat
171+
background: url('download_air.png') top center no-repeat
172172
cursor: no-drop
173173

174174
#git
175175
a
176-
background: url('/assets/download_git.png') top center no-repeat
176+
background: url('download_git.png') top center no-repeat
177177

178178
#keys
179179
padding: 0 0 15px 30px

app/jqapi.rb

100644100755
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,22 @@ class Jqapi < Sinatra::Base
4343
serve_file('docs/entries', "#{params[:splat][0]}.json")
4444
end
4545

46-
get '/resources/*.png' do
46+
get 'resources/*.png' do
4747
content_type 'image/png'
4848
serve_file('docs/resources', "#{params[:splat][0]}.png")
4949
end
5050

51-
get '/resources/*.jpg' do
51+
get 'resources/*.jpg' do
5252
content_type 'image/jpeg'
5353
serve_file('docs/resources', "#{params[:splat][0]}.jpg")
5454
end
5555

56-
get '/resources/*.gif' do
56+
get 'resources/*.gif' do
5757
content_type 'image/gif'
5858
serve_file('docs/resources', "#{params[:splat][0]}.gif")
5959
end
6060

61-
get '/LICENSE' do
61+
get 'LICENSE' do
6262
content_type 'text'
6363
serve_file('', 'LICENSE')
6464
end

app/views/index.haml

100644100755
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
%meta{:name => "content-type", :content => "text/html; charset=utf-8"}
77
%meta{:name => "description", :content => "Alternative jQuery Documentation Browser"}
88

9-
%link{:rel => "shortcut icon", :href => "/assets/favicon.ico", :type => "image/x-icon"}
9+
%link{:rel => "shortcut icon", :href => "assets/favicon.ico", :type => "image/x-icon"}
1010
%link{:rel => "icon", :href => "/favicon.ico", :type => "image/x-icon"}
11-
12-
%link{:href => '/assets/bundle.css', :type => 'text/css', :rel => 'stylesheet'}
13-
%script{:src => '/assets/bundle.js', :type => 'text/javascript'}
14-
11+
12+
%link{:href => 'assets/bundle.css', :type => 'text/css', :rel => 'stylesheet'}
13+
%script{:src => 'assets/bundle.js', :type => 'text/javascript'}
14+
1515
%body
1616
#sidebar
1717
#search
@@ -45,7 +45,7 @@
4545
%li
4646
%a{:href => '#changelog'}
4747
%span Changelog
48-
48+
4949
%ul#navigation
5050
%li
5151
%a{:href => '/'}
@@ -73,7 +73,7 @@
7373
\.
7474

7575
%p
76-
The aim of this project is to get out of the way of your development work.
76+
The aim of this project is to get out of the way of your development work.
7777
Quickly switch to this docs and find what you are looking for.
7878

7979
%p
@@ -134,7 +134,7 @@
134134
%ul.signatures
135135
%li.signature
136136
%h2.title Usage
137-
137+
138138
.row.clearfix
139139
.left
140140
%p
@@ -168,7 +168,7 @@
168168
%ul.signatures
169169
%li.signature#download
170170
%h2.title Download
171-
171+
172172
.row.clearfix
173173
.third#zip
174174
%a{:href => '/jqapi.zip'} Download as Zip Archive
@@ -230,7 +230,7 @@
230230
%ul.signatures
231231
%li.signature
232232
%h2.title License
233-
233+
234234
#license
235235
%div
236236
%a{:href => 'http://jquery.com'} jQuery
@@ -239,7 +239,7 @@
239239
\. jQAPI is
240240
%a{:href => 'https://github.com/jqapi/jqapi'}Open-Source
241241
and running under the same
242-
%a{:href => '/LICENSE'} licenses
242+
%a{:href => 'LICENSE'} licenses
243243
\.
244244
%div
245245
jQAPI is coded by
@@ -271,7 +271,7 @@
271271
Released very first version.
272272

273273
%a{:href => 'http://twitter.com/jqapi'} Follow @jqapi for updates
274-
274+
275275
:javascript
276276
if(window.location.hostname === 'jqapi.com') {
277277
var _gaq = _gaq || [];

0 commit comments

Comments
 (0)