Skip to content

Commit

Permalink
feat: updated for Ruby 3.X (patch compass)
Browse files Browse the repository at this point in the history
  • Loading branch information
rcmdnk committed Sep 2, 2024
1 parent 9a21973 commit 0a52ed3
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 68 deletions.
41 changes: 20 additions & 21 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
source "https://rubygems.org"
ruby "2.7.8"

group :development do
gem 'rake', '~> 13.0'
gem 'jekyll', '~> 4.3'
gem 'jekyll-sitemap', '~> 1.4'
gem 'compass', '~> 1.0'
gem 'sass-globbing', '~> 1.1'
gem 'stringex', '~> 2.8'
gem 'chronic', '~> 0.10'
gem 'gemoji', '~> 2.0'
gem 'google-analytics-data', '~> 0.4.0'
gem 'htmlcompressor', '~> 0.4'
gem 'jekyll-paginate', '~> 1.1'
gem 'json', '~> 2.6'
gem 'parallel', '~> 1.22'
gem 'pygments.rb', '~> 2.3'
gem 'ruby-progressbar', '~> 1.11'
gem 'thin', '~> 1.8'
gem 'sinatra', '~> 3.0'
gem 'xmlrpc', '~> 0.3'
gem 'yui-compressor', '~> 0.12'
gem 'chronic', '~> 0.10.2'
gem 'compass', '~> 1.0.3'
gem 'csv', '~> 3.3.0'
gem 'gemoji', '~> 4.1.0'
gem 'google-analytics-data', '~> 0.6.1'
gem 'htmlcompressor', '~> 0.4.0'
gem 'jekyll', '~> 4.3.3'
gem 'jekyll-paginate', '~> 1.1.0'
gem 'jekyll-sitemap', '~> 1.4.0'
gem 'json', '~> 2.7.2'
gem 'parallel', '~> 1.26.3'
gem 'pygments.rb', '~> 3.0.0'
gem 'rake', '~>13.2.1'
gem 'ruby-progressbar', '~> 1.13.0'
gem 'sass-globbing', '~> 1.1.5'
gem 'sinatra', '~> 3.0.0'
gem 'stringex', '~> 2.8.6'
gem 'thin', '~> 1.8.2'
gem 'xmlrpc', '~> 0.3.3'
gem 'yui-compressor', '~> 0.12.0'
end

11 changes: 6 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ html_for_minify = ["*.html", "blog/*/*/*/*/*.html"]
html_not_minify = []
precheck = false
n_cores = 8
compass = "ruby -r ./plugins/compass_monkey_patch.rb -S compass"

if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
puts '## Set the codepage to 65001 for Windows machines'
Expand Down Expand Up @@ -80,7 +81,7 @@ task :css, :style do |t, args|
if args.style
style = "-s #{args.style}"
end
ok_failed("compass compile #{style} --css-dir #{source_dir}/stylesheets")
ok_failed("#{compass} compile #{style} --css-dir #{source_dir}/stylesheets")
cp_r "#{source_dir}/stylesheets/.", "#{public_dir}/stylesheets/"
end

Expand Down Expand Up @@ -196,10 +197,10 @@ desc "Watch the site and regenerate when it changes"
task :watch do
raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
puts "Starting to watch source with Jekyll and Compass."
ok_failed("compass compile --css-dir #{source_dir}/stylesheets") unless File.exist?("#{source_dir}/stylesheets/screen.css")
ok_failed("#{compass} compile --css-dir #{source_dir}/stylesheets") unless File.exist?("#{source_dir}/stylesheets/screen.css")
ok_failed( "touch .preview-mode")
jekyllPid = Process.spawn("jekyll build --watch --unpublished")
compassPid = Process.spawn("compass watch")
compassPid = Process.spawn("#{compass} watch")

trap("INT") {
[jekyllPid, compassPid].each { |pid| Process.kill(9, pid) rescue Errno::ESRCH }
Expand Down Expand Up @@ -228,10 +229,10 @@ desc "preview the site in a web browser"
task :preview do
raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
puts "Starting to watch source with Jekyll and Compass. Starting Rack on port #{server_port}"
ok_failed("compass compile --css-dir #{source_dir}/stylesheets") unless File.exist?("#{source_dir}/stylesheets/screen.css")
ok_failed("#{compass} compile --css-dir #{source_dir}/stylesheets") unless File.exist?("#{source_dir}/stylesheets/screen.css")
ok_failed("touch .preview-mode")
jekyllPid = Process.spawn("jekyll build --watch --unpublished")
compassPid = Process.spawn("compass watch")
compassPid = Process.spawn("#{compass} watch")
rackupPid = Process.spawn("rackup --port #{server_port}")

trap("INT") {
Expand Down
46 changes: 23 additions & 23 deletions patches/Gemfile.patch
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
diff --git a/Gemfile b/Gemfile
index 5683812..5d6ceb3 100644
index 5683812..eaaee8c 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,18 +1,25 @@
@@ -1,18 +1,24 @@
source "https://rubygems.org"
+ruby "2.7.8"

group :development do
- gem 'rake', '~> 10.0'
Expand All @@ -19,25 +18,26 @@ index 5683812..5d6ceb3 100644
- gem 'sass-globbing', '~> 1.0.0'
- gem 'rb-fsevent', '~> 0.9'
- gem 'stringex', '~> 1.4.0'
+ gem 'rake', '~> 13.0'
+ gem 'jekyll', '~> 4.3'
+ gem 'jekyll-sitemap', '~> 1.4'
+ gem 'compass', '~> 1.0'
+ gem 'sass-globbing', '~> 1.1'
+ gem 'stringex', '~> 2.8'
+ gem 'chronic', '~> 0.10'
+ gem 'gemoji', '~> 2.0'
+ gem 'google-analytics-data', '~> 0.4.0'
+ gem 'htmlcompressor', '~> 0.4'
+ gem 'jekyll-paginate', '~> 1.1'
+ gem 'json', '~> 2.6'
+ gem 'parallel', '~> 1.22'
+ gem 'pygments.rb', '~> 2.3'
+ gem 'ruby-progressbar', '~> 1.11'
+ gem 'thin', '~> 1.8'
+ gem 'sinatra', '~> 3.0'
+ gem 'xmlrpc', '~> 0.3'
+ gem 'yui-compressor', '~> 0.12'
+ gem 'chronic', '~> 0.10.2'
+ gem 'compass', '~> 1.0.3'
+ gem 'csv', '~> 3.3.0'
+ gem 'gemoji', '~> 4.1.0'
+ gem 'google-analytics-data', '~> 0.6.1'
+ gem 'htmlcompressor', '~> 0.4.0'
+ gem 'jekyll', '~> 4.3.3'
+ gem 'jekyll-paginate', '~> 1.1.0'
+ gem 'jekyll-sitemap', '~> 1.4.0'
+ gem 'json', '~> 2.7.2'
+ gem 'parallel', '~> 1.26.3'
+ gem 'pygments.rb', '~> 3.0.0'
+ gem 'rake', '~>13.2.1'
+ gem 'ruby-progressbar', '~> 1.13.0'
+ gem 'sass-globbing', '~> 1.1.5'
+ gem 'sinatra', '~> 3.0.0'
+ gem 'stringex', '~> 2.8.6'
+ gem 'thin', '~> 1.8.2'
+ gem 'xmlrpc', '~> 0.3.3'
+ gem 'yui-compressor', '~> 0.12.0'
end
-
-gem 'sinatra', '~> 1.4.2'
53 changes: 34 additions & 19 deletions patches/Rakefile.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/Rakefile b/Rakefile
index 9367ea1..bd0ca80 100644
index 9367ea1..de8f694 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,6 +1,8 @@
Expand All @@ -11,7 +11,7 @@ index 9367ea1..bd0ca80 100644

## -- Rsync Deploy config -- ##
# Be sure your public key is listed in your server's ~/.ssh/authorized_keys file
@@ -9,27 +11,45 @@ ssh_port = "22"
@@ -9,27 +11,46 @@ ssh_port = "22"
document_root = "~/website.com/"
rsync_delete = false
rsync_args = "" # Any extra arguments to pass to rsync
Expand Down Expand Up @@ -54,6 +54,7 @@ index 9367ea1..bd0ca80 100644
+html_not_minify = []
+precheck = false
+n_cores = 8
+compass = "ruby -r ./plugins/compass_monkey_patch.rb -S compass"

if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
puts '## Set the codepage to 65001 for Windows machines'
Expand All @@ -62,7 +63,7 @@ index 9367ea1..bd0ca80 100644
end

desc "Initial setup for Octopress: copies the default theme into the path of Jekyll's generator. Rake install defaults to rake install[classic] to install a different theme run rake install[some_theme_name]"
@@ -52,47 +72,192 @@ end
@@ -52,47 +73,192 @@ end
# Working with Jekyll #
#######################

Expand All @@ -76,7 +77,7 @@ index 9367ea1..bd0ca80 100644
+ if args.style
+ style = "-s #{args.style}"
+ end
+ ok_failed("compass compile #{style} --css-dir #{source_dir}/stylesheets")
+ ok_failed("#{compass} compile #{style} --css-dir #{source_dir}/stylesheets")
+ cp_r "#{source_dir}/stylesheets/.", "#{public_dir}/stylesheets/"
+end
+
Expand Down Expand Up @@ -196,10 +197,11 @@ index 9367ea1..bd0ca80 100644
puts "Starting to watch source with Jekyll and Compass."
- system "compass compile --css-dir #{source_dir}/stylesheets" unless File.exist?("#{source_dir}/stylesheets/screen.css")
- jekyllPid = Process.spawn({"OCTOPRESS_ENV"=>"preview"}, "jekyll build --watch")
+ ok_failed("compass compile --css-dir #{source_dir}/stylesheets") unless File.exist?("#{source_dir}/stylesheets/screen.css")
- compassPid = Process.spawn("compass watch")
+ ok_failed("#{compass} compile --css-dir #{source_dir}/stylesheets") unless File.exist?("#{source_dir}/stylesheets/screen.css")
+ ok_failed( "touch .preview-mode")
+ jekyllPid = Process.spawn("jekyll build --watch --unpublished")
compassPid = Process.spawn("compass watch")
+ compassPid = Process.spawn("#{compass} watch")

trap("INT") {
[jekyllPid, compassPid].each { |pid| Process.kill(9, pid) rescue Errno::ESRCH }
Expand Down Expand Up @@ -231,10 +233,11 @@ index 9367ea1..bd0ca80 100644
puts "Starting to watch source with Jekyll and Compass. Starting Rack on port #{server_port}"
- system "compass compile --css-dir #{source_dir}/stylesheets" unless File.exist?("#{source_dir}/stylesheets/screen.css")
- jekyllPid = Process.spawn({"OCTOPRESS_ENV"=>"preview"}, "jekyll build --watch")
+ ok_failed("compass compile --css-dir #{source_dir}/stylesheets") unless File.exist?("#{source_dir}/stylesheets/screen.css")
- compassPid = Process.spawn("compass watch")
+ ok_failed("#{compass} compile --css-dir #{source_dir}/stylesheets") unless File.exist?("#{source_dir}/stylesheets/screen.css")
+ ok_failed("touch .preview-mode")
+ jekyllPid = Process.spawn("jekyll build --watch --unpublished")
compassPid = Process.spawn("compass watch")
+ compassPid = Process.spawn("#{compass} watch")
rackupPid = Process.spawn("rackup --port #{server_port}")

trap("INT") {
Expand Down Expand Up @@ -265,7 +268,7 @@ index 9367ea1..bd0ca80 100644
# usage rake new_post[my-new-post] or rake new_post['my new post'] or rake new_post (defaults to "new-post")
desc "Begin a new post in #{source_dir}/#{posts_dir}"
task :new_post, :title do |t, args|
@@ -102,20 +267,39 @@ task :new_post, :title do |t, args|
@@ -102,20 +268,39 @@ task :new_post, :title do |t, args|
title = get_stdin("Enter a title for your post: ")
end
raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
Expand Down Expand Up @@ -308,7 +311,7 @@ index 9367ea1..bd0ca80 100644
end
end

@@ -125,8 +309,10 @@ task :new_page, :filename do |t, args|
@@ -125,8 +310,10 @@ task :new_page, :filename do |t, args|
raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
args.with_defaults(:filename => 'new-page')
page_dir = [source_dir]
Expand All @@ -320,7 +323,7 @@ index 9367ea1..bd0ca80 100644
title = filename
page_dir.concat($1.downcase.sub(/^\//, '').split('/')) unless $1.nil? # Add path to page_dir Array
if extension.nil?
@@ -147,10 +333,13 @@ task :new_page, :filename do |t, args|
@@ -147,10 +334,13 @@ task :new_page, :filename do |t, args|
page.puts "---"
page.puts "layout: page"
page.puts "title: \"#{title}\""
Expand All @@ -335,7 +338,7 @@ index 9367ea1..bd0ca80 100644
page.puts "---"
end
else
@@ -161,21 +350,49 @@ end
@@ -161,21 +351,49 @@ end
# usage rake isolate[my-post]
desc "Move all other posts than the one currently being worked on to a temporary stash location (stash) so regenerating the site happens much more quickly."
task :isolate, :filename do |t, args|
Expand Down Expand Up @@ -392,7 +395,7 @@ index 9367ea1..bd0ca80 100644
end

desc "Move sass to sass.old, install sass theme updates, replace sass/custom with sass.old/custom"
@@ -215,8 +432,14 @@ end
@@ -215,8 +433,14 @@ end
##############

desc "Default deploy task"
Expand All @@ -409,7 +412,7 @@ index 9367ea1..bd0ca80 100644
if File.exists?(".preview-mode")
puts "## Found posts in preview mode, regenerating files ..."
File.delete(".preview-mode")
@@ -224,11 +447,32 @@ task :deploy do
@@ -224,11 +448,32 @@ task :deploy do
end

Rake::Task[:copydot].invoke(source_dir, public_dir)
Expand Down Expand Up @@ -444,7 +447,7 @@ index 9367ea1..bd0ca80 100644
end

desc "copy dot files for deployment"
@@ -245,74 +489,105 @@ task :rsync do
@@ -245,74 +490,105 @@ task :rsync do
exclude = "--exclude-from '#{File.expand_path('./rsync-exclude')}'"
end
puts "## Deploying website via Rsync"
Expand Down Expand Up @@ -573,7 +576,7 @@ index 9367ea1..bd0ca80 100644
repo_url = get_stdin("Repository url: ")
end
protocol = (repo_url.match(/(^git)@/).nil?) ? 'https' : 'git'
@@ -322,23 +597,25 @@ task :setup_github_pages, :repo do |t, args|
@@ -322,23 +598,25 @@ task :setup_github_pages, :repo do |t, args|
user = repo_url.match(/github\.com\/([^\/]+)/)[1]
end
branch = (repo_url.match(/\/[\w-]+\.github\.(?:io|com)/).nil?) ? 'gh-pages' : 'master'
Expand Down Expand Up @@ -610,7 +613,7 @@ index 9367ea1..bd0ca80 100644
end
end
url = blog_url(user, project, source_dir)
@@ -347,31 +624,56 @@ task :setup_github_pages, :repo do |t, args|
@@ -347,31 +625,56 @@ task :setup_github_pages, :repo do |t, args|
File.open('_config.yml', 'w') do |f|
f.write jekyll_config
end
Expand Down Expand Up @@ -689,7 +692,7 @@ index 9367ea1..bd0ca80 100644
end

def get_stdin(message)
@@ -379,9 +681,22 @@ def get_stdin(message)
@@ -379,9 +682,22 @@ def get_stdin(message)
STDIN.gets.chomp
end

Expand All @@ -714,7 +717,19 @@ index 9367ea1..bd0ca80 100644
else
answer = get_stdin(message)
end
@@ -404,3 +719,336 @@ task :list do
@@ -391,9 +707,9 @@ end
def blog_url(user, project, source_dir)
cname = "#{source_dir}/CNAME"
url = if File.exists?(cname)
- "http://#{IO.read(cname).strip}"
+ "https://#{IO.read(cname).strip}"
else
- "http://#{user.downcase}.github.io"
+ "https://#{user.downcase}.github.io"
end
url += "/#{project}" unless project == ''
url
@@ -404,3 +720,336 @@ task :list do
puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:list]]).join(', ')}"
puts "(type rake -T for more detail)\n\n"
end
Expand Down
7 changes: 7 additions & 0 deletions plugins_add/compass_monkey_patch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module FilePatch
def self.included(base)
base.singleton_class.alias_method :exists?, :exist?
end
end

File.include(FilePatch)

0 comments on commit 0a52ed3

Please sign in to comment.