├── .rspec ├── script ├── bootstrap ├── cibuild ├── release ├── fmt └── rebund ├── .gitignore ├── Rakefile ├── Gemfile ├── lib ├── jekyll-coffeescript │ └── version.rb ├── jekyll-coffeescript.rb └── jekyll │ └── converters │ └── coffeescript.rb ├── .rubocop.yml ├── .travis.yml ├── spec ├── spec_helper.rb └── coffeescript_spec.rb ├── jekyll-coffeescript.gemspec ├── LICENSE.txt ├── README.md └── History.markdown /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --format progress 3 | -------------------------------------------------------------------------------- /script/bootstrap: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | bundle install 4 | -------------------------------------------------------------------------------- /script/cibuild: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | bundle exec rspec 4 | -------------------------------------------------------------------------------- /script/release: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | bundle exec rake release 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .bundle 2 | Gemfile.lock 3 | pkg 4 | tmp 5 | vendor/bundle 6 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "bundler/gem_tasks" 4 | -------------------------------------------------------------------------------- /script/fmt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Rubocop $(bundle exec rubocop --version)" 3 | bundle exec rubocop -S -D $@ 4 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | gemspec 5 | 6 | gem "jekyll", ENV["JEKYLL_VERSION"] if ENV["JEKYLL_VERSION"] 7 | -------------------------------------------------------------------------------- /lib/jekyll-coffeescript/version.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Jekyll 4 | module Coffeescript 5 | VERSION = "2.0.0" 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | require: rubocop-jekyll 2 | 3 | inherit_gem: 4 | rubocop-jekyll: .rubocop.yml 5 | 6 | AllCops: 7 | TargetRubyVersion: 2.4 8 | Exclude: 9 | - vendor/**/* 10 | -------------------------------------------------------------------------------- /lib/jekyll-coffeescript.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "jekyll" 4 | require "jekyll-coffeescript/version" 5 | require "jekyll/converters/coffeescript" 6 | 7 | module Jekyll 8 | module Coffeescript 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/jekyll/converters/coffeescript.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Jekyll 4 | module Converters 5 | class CoffeeScript < Converter 6 | safe true 7 | priority :low 8 | 9 | def setup 10 | require "coffee-script" 11 | @setup = true 12 | end 13 | 14 | def matches(ext) 15 | ext.casecmp(".coffee").zero? 16 | end 17 | 18 | def output_ext(_ext) 19 | ".js" 20 | end 21 | 22 | def convert(content) 23 | setup unless @setup 24 | ::CoffeeScript.compile(content) 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | cache: bundler 3 | rvm: 4 | - &latest_ruby 2.7 5 | - 2.5 6 | env: 7 | matrix: 8 | - JEKYLL_VERSION="~> 3.9" 9 | matrix: 10 | include: 11 | - rvm: *latest_ruby 12 | env: JEKYLL_VERSION="~> 3.9" 13 | - rvm: *latest_ruby 14 | env: JEKYLL_VERSION="~> 4.2" 15 | - rvm: *latest_ruby 16 | script: script/fmt 17 | branches: 18 | only: 19 | - master 20 | install: 21 | - travis_retry script/bootstrap 22 | script: script/cibuild 23 | notifications: 24 | irc: 25 | on_success: change 26 | on_failure: change 27 | channels: 28 | - irc.freenode.org#jekyll 29 | template: 30 | - '%{repository}#%{build_number} %{message} %{build_url}' 31 | email: 32 | on_success: never 33 | on_failure: change 34 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # This file was generated by the `rspec --init` command. Conventionally, all 4 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. 5 | # Require this file using `require "spec_helper"` to ensure that it is only 6 | # loaded once. 7 | # 8 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration 9 | 10 | require "jekyll" 11 | require "jekyll-coffeescript" 12 | 13 | RSpec.configure do |config| 14 | config.run_all_when_everything_filtered = true 15 | config.filter_run :focus 16 | 17 | # Run specs in random order to surface order dependencies. If you find an 18 | # order dependency and want to debug it, you can fix the order by providing 19 | # the seed, which is printed after each run. 20 | # --seed 1234 21 | config.order = "random" 22 | end 23 | -------------------------------------------------------------------------------- /jekyll-coffeescript.gemspec: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require_relative "lib/jekyll-coffeescript/version" 4 | 5 | Gem::Specification.new do |spec| 6 | spec.name = "jekyll-coffeescript" 7 | spec.version = Jekyll::Coffeescript::VERSION 8 | spec.authors = ["Parker Moore"] 9 | spec.email = ["parkrmoore@gmail.com"] 10 | spec.summary = "A CoffeeScript converter for Jekyll." 11 | spec.homepage = "https://github.com/jekyll/jekyll-coffeescript" 12 | spec.license = "MIT" 13 | 14 | spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR).grep(%r!(lib/)!) 15 | spec.require_paths = ["lib"] 16 | 17 | spec.required_ruby_version = ">= 2.4.0" 18 | 19 | spec.add_runtime_dependency "coffee-script", "~> 2.2" 20 | spec.add_runtime_dependency "coffee-script-source", "~> 1.12" 21 | 22 | spec.add_development_dependency "bundler" 23 | spec.add_development_dependency "jekyll", "~> 4.0" 24 | spec.add_development_dependency "rake" 25 | spec.add_development_dependency "rspec" 26 | spec.add_development_dependency "rubocop-jekyll", "~> 0.11" 27 | end 28 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-present Parker Moore and jekyll-coffeescript contributors 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Jekyll::Coffeescript 2 | 3 | A CoffeeScript converter for Jekyll. 4 | 5 | [![Build Status](https://travis-ci.org/jekyll/jekyll-coffeescript.svg?branch=master)](https://travis-ci.org/jekyll/jekyll-coffeescript) 6 | 7 | ## Installation 8 | 9 | Add this line to your application's Gemfile: 10 | 11 | ```ruby 12 | gem 'jekyll-coffeescript' 13 | ``` 14 | 15 | And then execute: 16 | 17 | ```bash 18 | $ bundle 19 | ``` 20 | 21 | Or install it yourself as: 22 | 23 | ```bash 24 | $ gem install jekyll-coffeescript 25 | ``` 26 | 27 | **Notes: `jekyll-coffeescript` requires Ruby 2.4 or greater. Additionally, the dependency on `execjs` means you must also have a [valid JavaScript runtime](https://github.com/rails/execjs#execjs) available to your project** 28 | 29 | You also need to add this plugin to your `_config.yml` file: 30 | 31 | ``` 32 | plugins: 33 | - jekyll-coffeescript 34 | ``` 35 | 36 | ## Usage 37 | 38 | In your Jekyll site, create CoffeeScript files that start with the following 39 | lines: 40 | 41 | ``` 42 | --- 43 | --- 44 | ``` 45 | 46 | You need those three dashes in order for Jekyll to recognize it as 47 | "convertible". They won't be included in the content passed to the CoffeeScript 48 | compiler. 49 | 50 | ## Contributing 51 | 52 | 1. Fork it (`http://github.com/jekyll/jekyll-coffeescript/fork`) 53 | 2. Create your feature branch (`git checkout -b my-new-feature`) 54 | 3. Commit your changes (`git commit -am "Add some feature"`) 55 | 4. Push to the branch (`git push origin my-new-feature`) 56 | 5. Create new Pull Request 57 | -------------------------------------------------------------------------------- /History.markdown: -------------------------------------------------------------------------------- 1 | ## 2.0 / 2019-09-06 2 | 3 | ### Major Enhancements 4 | 5 | * Require Ruby 2.4 or greater (#38) 6 | * Require Jekyll 4.0 7 | 8 | ## 1.2.2 / 2019-03-24 9 | 10 | ### Bug Fixes 11 | 12 | * Revert `jekyll` to be just a `development_dependency` for `v1.x.x` series. 13 | 14 | ## 1.2.1 / 2019-03-23 15 | 16 | ### Bug Fixes 17 | 18 | * Re-introduce Ruby 2.3 support and test Jekyll 3.7+ (#33) 19 | 20 | ## 1.2.0 / 2019-03-22 21 | 22 | ### Development Fixes 23 | 24 | * Drop support for Ruby < 2.4 25 | * Allow Jekyll v4 (still alpha) 26 | * Style: Target Ruby 2.4 (#31) 27 | 28 | ### Documentation 29 | 30 | * Add essential step to readme (#32) 31 | 32 | ## 1.1.1 / 2018-02-03 33 | 34 | ### Development Fixes 35 | 36 | * Test against Ruby 2.5 (#25) 37 | 38 | ## 1.1.0 / 2017-12-03 39 | 40 | ### Development Fixes 41 | 42 | * Stop testing Ruby 1.9 (#17) 43 | * Test against Ruby 2.1 to 2.4 (#20) 44 | * Stop testing against Jekyll 2.5 (#22) 45 | * Define path with __dir__ (#18) 46 | * Inherit Jekyll's rubocop config for consistency (#19) 47 | * Add Rubocop to CI (#21) 48 | 49 | ## 1.0.2 / 2016-12-15 50 | 51 | * Lock coffee-script-source (#16) 52 | * Load converter only when used. (#11) 53 | * Test against Jekyll 2 & Jekyll 3 (#13) 54 | 55 | ## 1.0.1 / 2014-08-31 56 | 57 | ### Bug Fixes 58 | 59 | * `Converters::CoffeeScript#matches` should never return anything but `true` or `false` (#7) 60 | 61 | ### Development Fixes 62 | 63 | * Fix up some docs (#2) 64 | * Change CSS to JS in spec (#6) 65 | 66 | ## 1.0.0 / 2014-01-25 67 | 68 | * Birthday! 69 | -------------------------------------------------------------------------------- /spec/coffeescript_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "spec_helper" 4 | 5 | describe(Jekyll::Converters::CoffeeScript) do 6 | let(:configuration) { Jekyll::Configuration::DEFAULTS } 7 | let(:converter) do 8 | Jekyll::Converters::CoffeeScript.new(configuration) 9 | end 10 | let(:coffeescript_content) do 11 | <<~COFFEESCRIPT 12 | # Functions: 13 | square = (x) -> x * x 14 | 15 | # Arrays: 16 | list = [1, 2, 3, 4, 5] 17 | 18 | # Objects: 19 | math = 20 | root: Math.sqrt 21 | square: square 22 | cube: (x) -> x * square x 23 | COFFEESCRIPT 24 | end 25 | let(:js_content) do 26 | <<~JS 27 | (function() { 28 | var list, math, square; 29 | 30 | square = function(x) { 31 | return x * x; 32 | }; 33 | 34 | list = [1, 2, 3, 4, 5]; 35 | 36 | math = { 37 | root: Math.sqrt, 38 | square: square, 39 | cube: function(x) { 40 | return x * square(x); 41 | } 42 | }; 43 | 44 | }).call(this); 45 | JS 46 | end 47 | 48 | context "matching file extensions" do 49 | it "matches .coffee files" do 50 | expect(converter.matches(".coffee")).to be(true) 51 | end 52 | end 53 | 54 | context "determining the output file extension" do 55 | it "always outputs the .js file extension" do 56 | expect(converter.output_ext(".always-js-dont-matter")).to eql(".js") 57 | end 58 | end 59 | 60 | context "converting CoffeeScript" do 61 | it "produces JS" do 62 | expect(converter.convert(coffeescript_content)).to eql(js_content) 63 | end 64 | end 65 | end 66 | -------------------------------------------------------------------------------- /script/rebund: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # rebund(1) 4 | # 5 | # Author: Julien Letessier 6 | # Homepage: https://github.com/mezis/rebund 7 | # License: 8 | # 9 | # Copyright (c) 2014 HouseTrip Ltd 10 | # 11 | # MIT License 12 | # 13 | # Permission is hereby granted, free of charge, to any person obtaining 14 | # a copy of this software and associated documentation files (the 15 | # "Software"), to deal in the Software without restriction, including 16 | # without limitation the rights to use, copy, modify, merge, publish, 17 | # distribute, sublicense, and/or sell copies of the Software, and to 18 | # permit persons to whom the Software is furnished to do so, subject to 19 | # the following conditions: 20 | # 21 | # The above copyright notice and this permission notice shall be 22 | # included in all copies or substantial portions of the Software. 23 | # 24 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 25 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 26 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 27 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 28 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 29 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 30 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 | 32 | 33 | # Configuration 34 | : ${REBUND_CREDENTIALS:=user:secret} 35 | : ${REBUND_ENDPOINT=http://keyfile-production.herokuapp.com} 36 | : ${REBUND_TARBALL:=bundle.tbz} 37 | : ${REBUND_BUNDLE_DIR:=vendor/bundle} 38 | 39 | 40 | 41 | log() { 42 | echo "rebund: $*" > /dev/stderr 43 | } 44 | 45 | die() { 46 | echo "fatal: $*" > /dev/stderr 47 | exit 1 48 | } 49 | 50 | success() { 51 | log "$*" 52 | exit 0 53 | } 54 | 55 | on_error() { 56 | die 'unknown error.' 57 | } 58 | 59 | get_ruby_version() { 60 | bundle exec ruby --version 61 | } 62 | 63 | get_gemfile() { 64 | bundle exec sh -c 'echo $BUNDLE_GEMFILE' 65 | } 66 | 67 | calculate_hash() { 68 | (get_ruby_version ; cat $(get_gemfile)) | openssl sha256 | sed -e 's/.* //' 69 | } 70 | 71 | build_tarball() { 72 | test -e $REBUND_BUNDLE_DIR || die "cannot find bundle directory in ${REBUND_BUNDLE_DIR}" 73 | test -e $REBUND_TARBALL && success 'bundle already uploaded' 74 | tar jcf $REBUND_TARBALL $REBUND_BUNDLE_DIR 75 | } 76 | 77 | upload_tarball() { 78 | curl --fail \ 79 | -F filedata=@${REBUND_TARBALL} \ 80 | --digest --user $REBUND_CREDENTIALS \ 81 | ${REBUND_ENDPOINT}/$(calculate_hash) \ 82 | || success "could not upload bundle" 83 | } 84 | 85 | expand_tarball() { 86 | test -e $REBUND_TARBALL || success "no tarball" 87 | tar jxf $REBUND_TARBALL 88 | } 89 | 90 | download_tarball() { 91 | curl --fail \ 92 | --location \ 93 | -o ${REBUND_TARBALL} \ 94 | --digest --user $REBUND_CREDENTIALS \ 95 | ${REBUND_ENDPOINT}/$(calculate_hash) \ 96 | || success "could not download bundle" 97 | } 98 | 99 | rebund_upload() { 100 | build_tarball 101 | upload_tarball 102 | } 103 | 104 | rebund_download() { 105 | download_tarball 106 | expand_tarball 107 | } 108 | 109 | rebund_usage() { 110 | success "usage: $0 [-v] [upload|download]" 111 | } 112 | 113 | # cath errors 114 | trap on_error ERR 115 | 116 | # inherit the ERR trap in subprocesses 117 | set -E 118 | 119 | while test $# -gt 0 ; do 120 | case $1 in 121 | -v) 122 | set -x 123 | ;; 124 | upload) 125 | rebund_upload 126 | exit 0 127 | ;; 128 | download) 129 | rebund_download 130 | exit 0 131 | ;; 132 | *) 133 | rebund_usage 134 | exit 1 135 | ;; 136 | esac 137 | shift 138 | done 139 | 140 | rebund_usage 141 | --------------------------------------------------------------------------------