task-list-1.0.2/ 0000755 0000764 0000764 00000000000 12545214714 012466 5 ustar pravi pravi task-list-1.0.2/bower.json 0000644 0000764 0000764 00000000654 12545214714 014504 0 ustar pravi pravi {
"name": "task_list",
"version": "1.0.2",
"dependencies": {
"jquery": ">= 1.9.1"
},
"devDependencies": {
"qunit": ">= 1.0"
},
"main": [
"app/assets/javascripts/task_list.coffee",
"app/assets/stylesheets/task_list.scss"
],
"ignore": [
".gitignore",
".travis.yml",
"*.gemspec",
"*.md",
"config.ru",
"Gemfile",
"lib/",
"Rakefile",
"script/",
"test/"
]
}
task-list-1.0.2/LICENSE 0000644 0000764 0000764 00000002067 12545214714 013500 0 ustar pravi pravi The MIT License (MIT)
Copyright (c) 2014 GitHub, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
task-list-1.0.2/.travis.yml 0000644 0000764 0000764 00000000205 12545214714 014574 0 ustar pravi pravi language: ruby
install: ./script/bootstrap
script: ./script/cibuild
rvm:
- 1.9.3
- 2.0.0
- 2.1.1
notifications:
email: false
task-list-1.0.2/script/ 0000755 0000764 0000764 00000000000 12545214714 013772 5 ustar pravi pravi task-list-1.0.2/script/bootstrap 0000755 0000764 0000764 00000000426 12545214714 015737 0 ustar pravi pravi #!/bin/sh
set -e 0
if ! bundle check 1>/dev/null 2>&1; then
bundle install --no-color --binstubs --path vendor/gems
fi
if ! npm list bower 2>&1 | grep 0.8.5 >/dev/null; then
# npm install bower
npm install git://github.com/twitter/bower.git
fi
bower install --no-color
task-list-1.0.2/script/cibuild 0000755 0000764 0000764 00000000147 12545214714 015335 0 ustar pravi pravi #!/bin/sh -e
# Usage: script/cibuild
# CI build script.
./script/testsuite 4018
bundle exec rake test
task-list-1.0.2/script/testsuite 0000755 0000764 0000764 00000000620 12545214714 015747 0 ustar pravi pravi #!/usr/bin/env ruby
root = File.expand_path("../..", __FILE__)
Dir.chdir root
port = ARGV[0] || 4000
pid = fork do
$stderr.reopen "/dev/null" # silence WEBrick output
exec 'bundle', 'exec', 'rackup', '-p', port.to_s
end
sleep 1
status = system('phantomjs', "#{root}/test/run-qunit.coffee", "http://localhost:#{port}/test/index.html")
Process.kill 'SIGINT', pid
Process.wait pid
exit status
task-list-1.0.2/task-lists.gemspec 0000644 0000764 0000764 00000002047 12545214714 016134 0 ustar pravi pravi # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'task_list/version'
Gem::Specification.new do |gem|
gem.name = "task_list"
gem.version = TaskList::VERSION
gem.authors = ["Matt Todd"]
gem.email = ["matt@github.com"]
gem.description = %q{GitHub-flavored-Markdown TaskList components}
gem.summary = %q{GitHub-flavored-Markdown TaskList components}
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.require_paths = ["lib"]
gem.add_dependency "html-pipeline"
gem.add_development_dependency "github-markdown"
gem.add_development_dependency "rake"
gem.add_development_dependency "coffee-script"
gem.add_development_dependency "json"
gem.add_development_dependency "rack"
gem.add_development_dependency "sprockets"
gem.add_development_dependency "minitest", "~> 5.3.2"
end
task-list-1.0.2/README.md 0000644 0000764 0000764 00000003470 12545214714 013751 0 ustar pravi pravi # Task Lists
This package provides various components necessary for integrating
[Task Lists](https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments)
into your GitHub-flavored-Markdown user content.
## Components
The Task List feature is actually made of several different components:
* GitHub-flavored-Markdown Filter
* Model: summarizes task list items
* JavaScript: task list update behavior
* CSS: styles Markdown task list items
## Installation
Add this line to your application's Gemfile:
gem 'task_list'
And then execute:
$ bundle
### Rails 3+: Railtie method
``` ruby
# config/application.rb
require 'task_list/railtie'
```
### Rails 2.3: Manual method
Wherever you have your Sprockets setup:
``` ruby
Sprockets::Environment.new(Rails.root) do |env|
# Load TaskList assets
require 'task_list/railtie'
TaskList.asset_paths.each do |path|
env.append_path path
end
end
```
If you're not using Sprockets, you're on your own but it's pretty straight
forward. `task_list/railtie` defines `TaskList.asset_paths` which you can use
to manage building your asset bundles.
### CoffeeScript Requirements
Aside from requiring CoffeeScript, jQuery is the only other requirement.
## Testing and Development
JavaScript unit tests can be run with `script/testsuite`.
Ruby unit tests can be run with `rake test`.
Functional tests are more for manual testing in the browser. To run, install
the necessary components with `script/bootstrap` then run the server:
```
rackup -p 4011
```
Navigate to http://localhost:4011/test/functional/test_task_lists_behavior.html
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
task-list-1.0.2/config.ru 0000644 0000764 0000764 00000001122 12545214714 014277 0 ustar pravi pravi # Rack environment for testing purposes
require 'coffee-script'
require 'json'
require 'sprockets'
Root = File.expand_path("..", __FILE__)
Assets = Sprockets::Environment.new(Root) do |env|
env.append_path "bower_components"
env.append_path "app/assets/javascripts"
env.append_path "app/assets/stylesheets"
env.append_path "test"
end
map "/assets" do
run Assets
end
map "/update" do
run lambda { |env|
sleep 0.5
req = Rack::Request.new(env)
[200, {'Content-Type' => 'application/json'}, [req.params.to_json]]
}
end
map "/" do
run Rack::Directory.new(Root)
end
task-list-1.0.2/test/ 0000755 0000764 0000764 00000000000 12545214714 013445 5 ustar pravi pravi task-list-1.0.2/test/test_helper.rb 0000644 0000764 0000764 00000000100 12545214714 016277 0 ustar pravi pravi $:.unshift "lib"
require 'minitest/autorun'
require 'task_list'
task-list-1.0.2/test/units.css 0000644 0000764 0000764 00000000041 12545214714 015314 0 ustar pravi pravi /*= require qunit/qunit/qunit */
task-list-1.0.2/test/units.coffee 0000644 0000764 0000764 00000000071 12545214714 015756 0 ustar pravi pravi #= require qunit/qunit/qunit
#= require_directory ./unit
task-list-1.0.2/test/index.html 0000644 0000764 0000764 00000000417 12545214714 015444 0 ustar pravi pravi
task-list-1.0.2/test/task_list/ 0000755 0000764 0000764 00000000000 12545214714 015442 5 ustar pravi pravi task-list-1.0.2/test/task_list/filter_test.rb 0000644 0000764 0000764 00000006413 12545214714 020317 0 ustar pravi pravi # encoding: utf-8
require File.expand_path('../../test_helper', __FILE__)
require 'task_list/filter'
class TaskList::FilterTest < Minitest::Test
def setup
@pipeline = HTML::Pipeline.new [
HTML::Pipeline::MarkdownFilter,
TaskList::Filter
], {}, {}
@context = {}
@item_selector = "input.task-list-item-checkbox[type=checkbox]"
end
def test_filters_items_in_a_list
text = <<-md
- [ ] incomplete
- [x] complete
md
assert_equal 2, filter(text)[:output].css(@item_selector).size
end
def test_filters_items_with_HTML_contents
text = <<-md
- [ ] incomplete **with bold** text
- [x] complete __with italic__ text
md
assert_equal 2, filter(text)[:output].css(@item_selector).size
end
def test_filters_items_in_a_list_wrapped_in_paras
# See issue #7951 for details.
text = <<-md
- [ ] one
- [ ] this one will be wrapped in a para
- [ ] this one too, wtf
md
assert_equal 3, filter(text)[:output].css(@item_selector).size
end
def test_populates_result_with_task_list_items
text = <<-md
- [ ] incomplete
- [x] complete
md
result = filter(text)
assert !result[:task_list_items].empty?
incomplete, complete = result[:task_list_items]
assert incomplete
assert !incomplete.complete?
assert complete
assert complete.complete?
end
def test_skips_lists_in_code_blocks
code = <<-md
```
- [ ] incomplete
- [x] complete
```
md
assert filter(code)[:output].css(@item_selector).empty?,
"should not have any task list items"
end
def test_handles_encoding_correctly
unicode = "中文"
text = <<-md
- [ ] #{unicode}
md
assert item = filter(text)[:output].css('.task-list-item').pop
assert_equal unicode, item.text.strip
end
def test_handles_nested_items
text = <<-md
- [ ] one
- [ ] one.one
md
assert item = filter(text)[:output].css('.task-list-item .task-list-item').pop
end
def test_handles_complicated_nested_items
text = <<-md
- [ ] one
- [ ] one.one
- [x] one.two
- [ ] one.two.one
- [ ] one.two.two
- [ ] one.three
- [ ] one.four
- [ ] two
- [x] two.one
- [ ] two.two
- [ ] three
md
assert_equal 6 + 2, filter(text)[:output].css('.task-list-item .task-list-item').size
assert_equal 2, filter(text)[:output].css('.task-list-item .task-list-item .task-list-item').size
end
# NOTE: This is an edge case experienced regularly by users using a Swiss
# German keyboard.
# See: https://github.com/github/github/pull/18362
def test_non_breaking_space_between_brackets
text = "- [\xC2\xA0] ok"
assert item = filter(text)[:output].css('.task-list-item').pop, "item expected"
assert_equal 'ok', item.text.strip
end
# See: https://github.com/github/github/pull/18362
def test_non_breaking_space_between_brackets_in_paras
text = <<-md
- [\xC2\xA0] one
- [\xC2\xA0] this one will be wrapped in a para
- [\xC2\xA0] this one too, wtf
md
assert_equal 3, filter(text)[:output].css(@item_selector).size
end
def test_capital_X
text = <<-md
- [x] lower case
- [X] capital
md
assert_equal 2, filter(text)[:output].css("[checked]").size
end
protected
def filter(input, context = @context, result = nil)
result ||= {}
@pipeline.call(input, context, result)
end
end
task-list-1.0.2/test/task_list/summary_test.rb 0000644 0000764 0000764 00000001641 12545214714 020525 0 ustar pravi pravi # encoding: utf-8
require File.expand_path('../../test_helper', __FILE__)
require 'task_list/summary'
class TaskList::SummaryTest < Minitest::Test
def setup
@complete = make_item "[x]", "complete"
@incomplete = make_item "[ ]", "incomplete"
@items = [@complete, @incomplete]
@summary = make_summary @items
end
def test_no_items
summary = make_summary []
assert !summary.items?, "no task list items are expected"
end
def test_items
assert @summary.items?, "task list items are expected"
assert_equal 2, @summary.item_count
end
def test_complete_count
assert_equal 1, @summary.complete_count
end
def test_incomplete_count
assert_equal 1, @summary.incomplete_count
end
protected
def make_item(checkbox_text = "[ ]", source = "an item!")
TaskList::Item.new(checkbox_text, source)
end
def make_summary(items)
TaskList::Summary.new(items)
end
end
task-list-1.0.2/test/functional/ 0000755 0000764 0000764 00000000000 12545214714 015607 5 ustar pravi pravi task-list-1.0.2/test/functional/test_task_lists_behavior.html 0000644 0000764 0000764 00000005332 12545214714 023576 0 ustar pravi pravi
I'm a task list item
with non-breaking space
completed, lower
completed capitalized
task-list-1.0.2/test/functional/helpers/ 0000755 0000764 0000764 00000000000 12545214714 017251 5 ustar pravi pravi task-list-1.0.2/test/functional/helpers/remote.coffee 0000644 0000764 0000764 00000000111 12545214714 021706 0 ustar pravi pravi #= require jquery
#= require rails-behaviors/remote
#= require task_list
task-list-1.0.2/test/unit/ 0000755 0000764 0000764 00000000000 12545214714 014424 5 ustar pravi pravi task-list-1.0.2/test/unit/test_events.coffee 0000644 0000764 0000764 00000003733 12545214714 020146 0 ustar pravi pravi #= require task_list
module "TaskList events",
setup: ->
@container = $ '