Skip to content

Modified structure to fix compass watch error, issue #10 #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.bundle/
.sass-cache/
.DS_Store
tmp/**/*
tmp/**/*
.env
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ gem 'haml'
# Sass & Compass
gem 'sass'
gem 'compass'

#Twitter Bootstrap
gem 'bootstrap-sass'
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
GEM
remote: https://rubygems.org/
specs:
bootstrap-sass (3.0.3.0)
sass (~> 3.2)
chunky_png (1.2.8)
compass (0.12.2)
chunky_png (~> 1.2)
Expand All @@ -26,6 +28,7 @@ PLATFORMS
ruby

DEPENDENCIES
bootstrap-sass
compass
haml
rake
Expand Down
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: bundle exec rackup config.ru -p $PORT
8 changes: 7 additions & 1 deletion app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
require 'sinatra/base'
require 'haml'

require_relative 'helpers/render_partial'

class SinatraBootstrap < Sinatra::Base
require './helpers/render_partial'
helpers RenderPartial

configure do
$stdout.sync = true
end

get '/' do
haml :index
Expand Down
1 change: 1 addition & 0 deletions config.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require './app'
require 'bootstrap-sass'

# Configuration to use when running within Sinatra
project_path = Sinatra::Application.root
Expand Down
4 changes: 1 addition & 3 deletions helpers/render_partial.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ module RenderPartial
def partial(page, options={})
haml page, options.merge!(:layout => false)
end
end

helpers RenderPartial
end
126 changes: 126 additions & 0 deletions public/javascripts/bootstrap/affix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/* ========================================================================
* Bootstrap: affix.js v3.0.3
* http://getbootstrap.com/javascript/#affix
* ========================================================================
* Copyright 2013 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ======================================================================== */


+function ($) { "use strict";

// AFFIX CLASS DEFINITION
// ======================

var Affix = function (element, options) {
this.options = $.extend({}, Affix.DEFAULTS, options)
this.$window = $(window)
.on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
.on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))

this.$element = $(element)
this.affixed =
this.unpin = null

this.checkPosition()
}

Affix.RESET = 'affix affix-top affix-bottom'

Affix.DEFAULTS = {
offset: 0
}

Affix.prototype.checkPositionWithEventLoop = function () {
setTimeout($.proxy(this.checkPosition, this), 1)
}

Affix.prototype.checkPosition = function () {
if (!this.$element.is(':visible')) return

var scrollHeight = $(document).height()
var scrollTop = this.$window.scrollTop()
var position = this.$element.offset()
var offset = this.options.offset
var offsetTop = offset.top
var offsetBottom = offset.bottom

if (typeof offset != 'object') offsetBottom = offsetTop = offset
if (typeof offsetTop == 'function') offsetTop = offset.top()
if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()

var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false :
offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' :
offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false

if (this.affixed === affix) return
if (this.unpin) this.$element.css('top', '')

this.affixed = affix
this.unpin = affix == 'bottom' ? position.top - scrollTop : null

this.$element.removeClass(Affix.RESET).addClass('affix' + (affix ? '-' + affix : ''))

if (affix == 'bottom') {
this.$element.offset({ top: document.body.offsetHeight - offsetBottom - this.$element.height() })
}
}


// AFFIX PLUGIN DEFINITION
// =======================

var old = $.fn.affix

$.fn.affix = function (option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.affix')
var options = typeof option == 'object' && option

if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
if (typeof option == 'string') data[option]()
})
}

$.fn.affix.Constructor = Affix


// AFFIX NO CONFLICT
// =================

$.fn.affix.noConflict = function () {
$.fn.affix = old
return this
}


// AFFIX DATA-API
// ==============

$(window).on('load', function () {
$('[data-spy="affix"]').each(function () {
var $spy = $(this)
var data = $spy.data()

data.offset = data.offset || {}

if (data.offsetBottom) data.offset.bottom = data.offsetBottom
if (data.offsetTop) data.offset.top = data.offsetTop

$spy.affix(data)
})
})

}(jQuery);
98 changes: 98 additions & 0 deletions public/javascripts/bootstrap/alert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/* ========================================================================
* Bootstrap: alert.js v3.0.3
* http://getbootstrap.com/javascript/#alerts
* ========================================================================
* Copyright 2013 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ======================================================================== */


+function ($) { "use strict";

// ALERT CLASS DEFINITION
// ======================

var dismiss = '[data-dismiss="alert"]'
var Alert = function (el) {
$(el).on('click', dismiss, this.close)
}

Alert.prototype.close = function (e) {
var $this = $(this)
var selector = $this.attr('data-target')

if (!selector) {
selector = $this.attr('href')
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
}

var $parent = $(selector)

if (e) e.preventDefault()

if (!$parent.length) {
$parent = $this.hasClass('alert') ? $this : $this.parent()
}

$parent.trigger(e = $.Event('close.bs.alert'))

if (e.isDefaultPrevented()) return

$parent.removeClass('in')

function removeElement() {
$parent.trigger('closed.bs.alert').remove()
}

$.support.transition && $parent.hasClass('fade') ?
$parent
.one($.support.transition.end, removeElement)
.emulateTransitionEnd(150) :
removeElement()
}


// ALERT PLUGIN DEFINITION
// =======================

var old = $.fn.alert

$.fn.alert = function (option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.alert')

if (!data) $this.data('bs.alert', (data = new Alert(this)))
if (typeof option == 'string') data[option].call($this)
})
}

$.fn.alert.Constructor = Alert


// ALERT NO CONFLICT
// =================

$.fn.alert.noConflict = function () {
$.fn.alert = old
return this
}


// ALERT DATA-API
// ==============

$(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)

}(jQuery);
Loading