• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

github/task_list: GitHub flavor Markdown Task List feature components

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

github/task_list

开源软件地址(OpenSource Url):

https://github.com/github/task_list

开源编程语言(OpenSource Language):

CoffeeScript 57.7%

开源软件介绍(OpenSource Introduction):

Task Lists

NOTE: This repository is no longer supported or updated by GitHub. If you wish to continue to develop this code yourself, we recommend you fork it.

Gem Version Build Status Dependency Status Inline docs

This package provides various components necessary for integrating Task Lists into your GitHub-flavored-Markdown user content.

Components

The Task List feature is made of several different components:

  • GitHub-flavored-Markdown Ruby Filter
  • Summary Ruby Model: summarizes task list items
  • JavaScript: frontend task list update behavior
  • CSS: styles Markdown task list items

Usage & Integration

The backend components are designed for rendering the Task List item checkboxes, and the frontend components handle updating the Markdown source (embedded in the markup).

Backend: Markdown pipeline filter

Rendering Task List item checkboxes from source Markdown depends on the TaskList::Filter, designed to integrate with the html-pipeline gem. For example:

require 'html/pipeline'
require 'task_list/filter'

pipeline = HTML::Pipeline.new [
  HTML::Pipeline::MarkdownFilter,
  TaskList::Filter
]

pipeline.call "- [ ] task list item"

Frontend: Markdown Updates

Task List updates on the frontend require specific HTML markup structure, and must be enabled with JavaScript.

Rendered HTML (the <ul> element below) should be contained in a js-task-list-container container element and include a sibling textarea.js-task-list-field element that is updated when checkboxes are changed.

- [ ] text
<div class="js-task-list-container">
  <ul class="task-list">
    <li class="task-list-item">
      <input type="checkbox" class="js-task-list-item-checkbox" disabled />
      text
    </li>
  </ul>
  <form>
    <textarea class="js-task-list-field">- [ ] text</textarea>
  </form>
</div>

Enable Task List updates with:

$('.js-task-list-container').taskList('enable')

NOTE: Updates are not persisted to the server automatically. Persistence is the responsibility of the integrating application, accomplished by hooking into the tasklist:change JavaScript event. For instance, we use AJAX to submit a hidden form on update.

Read through the documented behaviors and samples in the source for more detail, including documented events.

Installation

Task Lists are packaged as both a RubyGem with both backend and frontend behavior, and a Bower package with just the frontend behavior.

Backend: RubyGem

For the backend Ruby components, add this line to your application's Gemfile:

gem 'task_list'

And then execute:

$ bundle

Frontend: Bower

For the frontend components, add task_list to your Bower dependencies config.

This is the preferred method for including the frontend assets in your application. Alternatively, for Rails methods using Sprockets, see below.

Frontend: Rails 3+ Railtie method

# config/application.rb
require 'task_list/railtie'

Frontend: Rails 2.3 Manual method

Wherever you have your Sprockets setup:

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.

Dependencies

At a high level, the Ruby components integrate with the html-pipeline library, and the frontend components depend on the jQuery library. The frontend components are written in CoffeeScript and need to be preprocessed for production use.

Testing and Development

JavaScript unit tests can be run with script/testsuite.

Ruby unit tests can be run with rake test.

Functional tests are useful 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

Community Integration

Contributing

Read the Contributing Guidelines and open a Pull Request!




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap