Skip to content

Commit

Permalink
Merge pull request #4 from Klortho/master
Browse files Browse the repository at this point in the history
Load assets from a relative path instead of a absolute, instructions in Readme, added execjs and therubyracer to Gemfile
  • Loading branch information
mustardamus committed Jan 15, 2013
2 parents b83dbb8 + 919ad7b commit dadfba8
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 43 deletions.
5 changes: 4 additions & 1 deletion Gemfile
Expand Up @@ -8,4 +8,7 @@ gem 'sass'
gem 'coffee-script'
gem 'haml'
gem 'sinatra'
gem 'crack'
gem 'crack'

gem 'execjs'
gem 'therubyracer'
7 changes: 7 additions & 0 deletions README.md 100644 → 100755
Expand Up @@ -41,6 +41,13 @@ The GitHub repo of the official docs site will be cloned/updated.
Point your browser to localhost:9292 and there you have the latest jQuery documentation with jQAPI
wrapped around.

### Generate static files

thor deploy:generate

Generates index.html, bundle.js, bundle.css, etc., so that the documentation can be
viewed from a set of static files.

## Known Issues - Work in progress
- check if method is deprecated, if so indicate it
- jQuery() documentation is broken
Expand Down
8 changes: 4 additions & 4 deletions app/assets/javascripts/categories.js.coffee 100644 → 100755
Expand Up @@ -2,7 +2,7 @@ class jqapi.Categories
constructor: ->
@el = $ '#categories' # parent ul element
self = @

jqapi.events.on 'navigation:done', => # call when everything is loaded and generated
@hideLoader() # hide the loader

Expand All @@ -14,8 +14,8 @@ class jqapi.Categories

jqapi.events.on 'categories:toggle', (e, catEl) => # on request to toggle a category
@toggleCategory catEl # toggle the category content
$.getJSON '/docs/index.json', (data) => # load the index json data with all categories and entries

$.getJSON 'docs/index.json', (data) => # load the index json data with all categories and entries
@buildNavigation data # and build from the object when loaded
jqapi.events.trigger 'index:done', [data] # let the app know that the index is loaded

Expand Down Expand Up @@ -58,7 +58,7 @@ class jqapi.Categories
if subcats and subcats.length # are there any sub categories?
for subcat in subcats # for each sub category
listEl = $ templates.categoryItem('sub', subcat.name) # get template for category

if subcat.entries.length # if the sub category has entries
listEl.append @buildEntriesList(subcat.entries) # build and append the entries
listEl.appendTo el # append entries list to category
Expand Down
14 changes: 7 additions & 7 deletions app/assets/javascripts/entry.js.coffee 100644 → 100755
Expand Up @@ -19,15 +19,15 @@ class jqapi.Entry
document.title = "#{entry.title} - jQAPI" # set a new title

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

parseEntry: (entry) ->
el = $ templates.entry(entry) # generate element from template

#@insertCategories entry, el # generate and insert categories
@insertEntries entry, el # generate entries and insert

Expand All @@ -36,7 +36,7 @@ class jqapi.Entry
@highlightCode()
@adjustCodeHeight() # set equal heights for the code boxes
@fixLinks()

insertCategories: (entry, el) ->
catsEl = $('#categories', el) # cache categories list

Expand Down Expand Up @@ -143,7 +143,7 @@ class jqapi.Entry
playH -= cssEl.height() if cssEl.length
playH += 100 if playH < 100
playH = 130 if playH < 0

sandboxEl.children('.play').height playH

fixLinks: ->
Expand All @@ -161,9 +161,9 @@ class jqapi.Entry
if hrefArr[2] is 'api.jquery.com'
href = hrefArr[hrefArr.length - 1]
href = hrefArr[hrefArr.length - 2] if href.length is 0

el.attr 'href', "#p=#{href}"

buildLiveExamples: ->
sandboxEls = $('.sandbox', @el)

Expand All @@ -178,5 +178,5 @@ class jqapi.Entry
js : el.find('.js pre').text()
css : el.find('.css pre').text()
external:
js : ['/assets/jquery.js']
js : ['assets/jquery.js']
el : $('.play', sandboxEl).text('')
14 changes: 7 additions & 7 deletions app/assets/stylesheets/categories.css.sass 100644 → 100755
Expand Up @@ -2,21 +2,21 @@
.loader
text-align: center
padding-top: 20px

.top-cat
.top-cat-name
display: block
background: url('/assets/arrow.png') no-repeat #ddd
background: url('arrow.png') no-repeat #ddd
border-bottom: 1px solid #ccc
padding: 7px 0 7px 25px
cursor: pointer

.top-cat-name:hover, &.hover .top-cat-name
background: url('/assets/arrow.png') 0 -27px no-repeat #cecece
background: url('arrow.png') 0 -27px no-repeat #cecece
border-bottom: 1px solid rgba(0, 0, 0, 0.1)
box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.2)
color: #111

.sub-cats
display: none

Expand All @@ -28,14 +28,14 @@
border-bottom: 1px dotted #ddd
padding: 7px 0 7px 25px
cursor: pointer

.sub-cat-name:hover, &.hover .sub-cat-name
background: #dedede
border-bottom: 1px solid #d3d3d3

.open, .open.hover
.top-cat-name, .top-cat-name:hover
background: url('/assets/arrow.png') 0 -54px no-repeat #cecece
background: url('arrow.png') 0 -54px no-repeat #cecece
border-bottom: 1px solid rgba(0, 0, 0, 0.1)
box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.2)
color: #111
Expand Down
4 changes: 2 additions & 2 deletions app/assets/stylesheets/entry.css.sass 100644 → 100755
Expand Up @@ -4,8 +4,8 @@
height: 400px

&.loading
background: url('/assets/loader.gif') no-repeat center center
background: url('loader.gif') no-repeat center center

#entry-wrapper
padding: 20px 30px

Expand Down
12 changes: 6 additions & 6 deletions app/assets/stylesheets/main.css.sass 100644 → 100755
@@ -1,6 +1,6 @@
html
font-size: 16px

body
font-size: 62.5%
font-family: "Helvetica Neue", Arial, sans-serif
Expand Down Expand Up @@ -78,7 +78,7 @@ body
display: block
width: 264px
height: 61px
background: url('/assets/hashrocket.png') no-repeat
background: url('hashrocket.png') no-repeat
text-indent: -30000px

#credits
Expand Down Expand Up @@ -120,7 +120,7 @@ body

#changelog
position: relative

a
position: absolute
top: 55px
Expand Down Expand Up @@ -164,16 +164,16 @@ body

#zip
a
background: url('/assets/download_zip.png') top center no-repeat
background: url('download_zip.png') top center no-repeat

#air
a
background: url('/assets/download_air.png') top center no-repeat
background: url('download_air.png') top center no-repeat
cursor: no-drop

#git
a
background: url('/assets/download_git.png') top center no-repeat
background: url('download_git.png') top center no-repeat

#keys
padding: 0 0 15px 30px
Expand Down
8 changes: 4 additions & 4 deletions app/jqapi.rb 100644 → 100755
Expand Up @@ -43,22 +43,22 @@ class Jqapi < Sinatra::Base
serve_file('docs/entries', "#{params[:splat][0]}.json")
end

get '/resources/*.png' do
get 'resources/*.png' do
content_type 'image/png'
serve_file('docs/resources', "#{params[:splat][0]}.png")
end

get '/resources/*.jpg' do
get 'resources/*.jpg' do
content_type 'image/jpeg'
serve_file('docs/resources', "#{params[:splat][0]}.jpg")
end

get '/resources/*.gif' do
get 'resources/*.gif' do
content_type 'image/gif'
serve_file('docs/resources', "#{params[:splat][0]}.gif")
end

get '/LICENSE' do
get 'LICENSE' do
content_type 'text'
serve_file('', 'LICENSE')
end
Expand Down
24 changes: 12 additions & 12 deletions app/views/index.haml 100644 → 100755
Expand Up @@ -6,12 +6,12 @@
%meta{:name => "content-type", :content => "text/html; charset=utf-8"}
%meta{:name => "description", :content => "Alternative jQuery Documentation Browser"}

%link{:rel => "shortcut icon", :href => "/assets/favicon.ico", :type => "image/x-icon"}
%link{:rel => "shortcut icon", :href => "assets/favicon.ico", :type => "image/x-icon"}
%link{:rel => "icon", :href => "/favicon.ico", :type => "image/x-icon"}
%link{:href => '/assets/bundle.css', :type => 'text/css', :rel => 'stylesheet'}
%script{:src => '/assets/bundle.js', :type => 'text/javascript'}

%link{:href => 'assets/bundle.css', :type => 'text/css', :rel => 'stylesheet'}
%script{:src => 'assets/bundle.js', :type => 'text/javascript'}

%body
#sidebar
#search
Expand Down Expand Up @@ -45,7 +45,7 @@
%li
%a{:href => '#changelog'}
%span Changelog

%ul#navigation
%li
%a{:href => '/'}
Expand Down Expand Up @@ -73,7 +73,7 @@
\.

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

%p
Expand Down Expand Up @@ -134,7 +134,7 @@
%ul.signatures
%li.signature
%h2.title Usage

.row.clearfix
.left
%p
Expand Down Expand Up @@ -168,7 +168,7 @@
%ul.signatures
%li.signature#download
%h2.title Download

.row.clearfix
.third#zip
%a{:href => '/jqapi.zip'} Download as Zip Archive
Expand Down Expand Up @@ -230,7 +230,7 @@
%ul.signatures
%li.signature
%h2.title License

#license
%div
%a{:href => 'http://jquery.com'} jQuery
Expand All @@ -239,7 +239,7 @@
\. jQAPI is
%a{:href => 'https://github.com/jqapi/jqapi'}Open-Source
and running under the same
%a{:href => '/LICENSE'} licenses
%a{:href => 'LICENSE'} licenses
\.
%div
jQAPI is coded by
Expand Down Expand Up @@ -271,7 +271,7 @@
Released very first version.

%a{:href => 'http://twitter.com/jqapi'} Follow @jqapi for updates

:javascript
if(window.location.hostname === 'jqapi.com') {
var _gaq = _gaq || [];
Expand Down

0 comments on commit dadfba8

Please sign in to comment.