Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David Christiansen
committed
Dec 11, 2012
1 parent
a48666f
commit 8e4187c
Showing
14 changed files
with
448 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in twitter-bootstrap-calendar.gemspec | ||
gemspec | ||
source "http://rubygems.org" | ||
|
||
# Specify your gem's dependencies in twitter-bootstrap-rails.gemspec | ||
gemspec | ||
gem 'less-rails', :path => ENV['LESS_RAILS_SOURCE'] if ENV['LESS_RAILS_SOURCE'] | ||
|
||
group :test do | ||
gem 'minitest' | ||
gem 'mocha' | ||
gem 'rake' | ||
gem 'turn' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,34 @@ | ||
#!/usr/bin/env rake | ||
require "bundler/gem_tasks" | ||
#!/usr/bin/env rake | ||
require 'bundler' | ||
Bundler::GemHelper.install_tasks | ||
|
||
desc "Bundle the gem" | ||
task :bundle do | ||
sh('bundle install') | ||
sh 'gem build *.gemspec' | ||
sh 'gem install *.gem' | ||
sh 'rm *.gem' | ||
end | ||
|
||
# desc "Build the static precompiled stylesheets from Less sources" | ||
# task :build_static_stylesheets do | ||
# require 'less' | ||
|
||
# toolkit_path = File.join('vendor', 'toolkit') | ||
|
||
# parser = Less::Parser.new :paths => [toolkit_path] | ||
|
||
# target_directory = File.expand_path('vendor/assets/stylesheets/twitter-bootstrap-static') | ||
|
||
# sh "rm -rf #{target_directory}" | ||
# sh "mkdir -p #{target_directory}" | ||
# Dir['vendor/static-source/*.less'].each do |source_file| | ||
# puts "Compiling #{source_file}" | ||
# target_file = File.join(target_directory, File.basename(source_file, '.less')+'.css.erb') | ||
# tree = parser.parse(File.read(source_file)) | ||
# File.open(target_file, 'w') {|f| f.puts tree.to_css(:compress => true) } | ||
# end | ||
# end | ||
|
||
task(:default).clear | ||
task :default => :bundle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
module BootstrapCalendarHelper | ||
def bootstrap_calendar(date = Date.today, &block) | ||
BootstrapCalendar.new(self, date, block).calendar_div | ||
end | ||
|
||
BootstrapCalendar = Struct.new(:view, :date, :callback) do | ||
HEADER = %w[Sunday Monday Tuesday Wednesday Thursday Friday Saturday] | ||
START_DAY = :sunday | ||
|
||
delegate :content_tag, to: :view | ||
|
||
def calendar_div | ||
content_tag 'div', class: "calendar_grid" do | ||
header + week_rows | ||
end | ||
end | ||
|
||
def header | ||
content_tag 'div', class: 'month_header row-fluid' do | ||
HEADER.map { |day| content_tag :div, class: 'span1' do | ||
day | ||
end }.join.html_safe | ||
end | ||
end | ||
|
||
def week_rows | ||
weeks.map {|week| | ||
content_tag :div, class: 'row-fluid week' do | ||
week.map { |day| day_cell(day) }.join.html_safe | ||
end | ||
}.join.html_safe | ||
end | ||
|
||
def day_cell(day) | ||
content_tag :div, view.capture(day, &callback), class: day_classes(day) | ||
end | ||
|
||
def day_classes(day) | ||
classes = ['span1'] | ||
classes << "today" if day == Date.today | ||
classes << "notmonth" if day.month != date.month | ||
classes << "month" if day.month == date.month | ||
classes.empty? ? nil : classes.join(" ") | ||
end | ||
|
||
def weeks | ||
first = date.beginning_of_month.beginning_of_week(START_DAY) | ||
last = date.end_of_month.end_of_week(START_DAY) | ||
(first..last).to_a.in_groups_of(7) | ||
end | ||
end | ||
|
||
def event_style(event) | ||
"background-color: #{event.color};" | ||
end | ||
|
||
def event_link_style(event) | ||
if %w(white silver yellow lime aqua teal fuchsia).include?(event.color) | ||
"color: black;" | ||
else | ||
"color: white;" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
require "twitter-bootstrap-calendar/version" | ||
|
||
module Twitter | ||
module Bootstrap | ||
module Calendar | ||
# Your code goes here... | ||
end | ||
end | ||
end | ||
module Twitter | ||
module Bootstrap | ||
module Calendar | ||
require 'twitter/bootstrap/calendar/engine' if defined?(Rails) | ||
end | ||
end | ||
end | ||
|
||
require 'twitter/bootstrap/calendar/bootstrap' if defined?(Rails) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require "twitter/bootstrap/calendar/engine" | ||
require "twitter/bootstrap/calendar/version" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'rails' | ||
|
||
require File.dirname(__FILE__) + '/../../../../app/helpers/bootstrap_calendar_helper.rb' | ||
|
||
module Twitter | ||
module Bootstrap | ||
module Calendar | ||
class Engine < ::Rails::Engine | ||
initializer 'twitter-bootstrap-calendar.setup_helpers' do |app| | ||
app.config.to_prepare do | ||
ActionController::Base.send :helper, BootstrapCalendarHelper | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require "bundler/setup" | ||
Bundler.require | ||
|
||
require "minitest/autorun" | ||
require "abstract_controller" | ||
require "action_controller" | ||
require "active_support/dependencies" | ||
require "mocha/setup" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
# -*- encoding: utf-8 -*- | ||
require File.expand_path('../lib/twitter-bootstrap-calendar/version', __FILE__) | ||
$:.push File.expand_path("../lib", __FILE__) | ||
require "twitter/bootstrap/calendar/version" | ||
|
||
Gem::Specification.new do |gem| | ||
gem.authors = ["David Christiansen"] | ||
gem.email = ["dave@developertown.com"] | ||
gem.description = %q{TODO: Write a gem description} | ||
gem.summary = %q{TODO: Write a gem summary} | ||
gem.homepage = "" | ||
Gem::Specification.new do |s| | ||
s.name = "twitter-bootstrap-calendar" | ||
s.version = Twitter::Bootstrap::Calendar::VERSION | ||
s.platform = Gem::Platform::RUBY | ||
s.authors = ["David Christiansen"] | ||
s.email = ["dave@trooptrack.com"] | ||
s.homepage = "https://github.com/davidray/twitter-bootstrap-calendar" | ||
s.summary = %q{Bootstrap based responsive calendar} | ||
s.description = %q{Adds a helper and 7-column grid for creating calendar views} | ||
|
||
gem.files = `git ls-files`.split($\) | ||
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } | ||
gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) | ||
gem.name = "twitter-bootstrap-calendar" | ||
gem.require_paths = ["lib"] | ||
gem.version = Twitter::Bootstrap::Calendar::VERSION | ||
s.files = Dir["lib/**/*"] + Dir["vendor/**/*"] + Dir["app/**/*"] + ["Rakefile", "README.md"] | ||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | ||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } | ||
s.require_paths = ["lib"] | ||
|
||
s.add_dependency 'sass' | ||
s.add_dependency 'railties', '>= 3.1' | ||
s.add_dependency 'actionpack', '>= 3.1' | ||
# s.add_runtime_dependency 'execjs' | ||
s.add_development_dependency 'rails', '>= 3.1' | ||
# s.add_development_dependency 'less' | ||
# s.add_development_dependency 'therubyracer', '0.10.2' | ||
end |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.