Skip to content

Instantly share code, notes, and snippets.

@parkr
Last active December 18, 2015 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parkr/5745276 to your computer and use it in GitHub Desktop.
Save parkr/5745276 to your computer and use it in GitHub Desktop.
octopress-todos
1. Create Scaffolder for Plugins/Themes
1. Create proper gem structure so it can plugin to our
2. Rake tasks
- rake validate
- rake release
- rake build (put in pkg/)
- rake test (SEE test.rake)
3. Questions:
- How should the CLI look? (take all args after the keyword and join to make the name)
1. `octopress scaffold theme NAME`
2. `octopress scaffold plugin NAME`
- What should the content be?
1. Theme:
- octopress/
- configs/
- includes/
- layouts/
- javascripts/
- javascripts/lib
- javascripts/modules
- source/
- stylesheets/
- plugins/
- HOWTO.markdown
- lib/
- lib/rake
- lib/the_name.rb
- Rakefile (with helpful tasks for gem deployment)
- spec/
- spec/spec_helper.rb
- spec/the_name_spec.rb
- the_name.gemspec
2. Move logic from .rake files in lib/rake to Ruby files in lib/octopress/commands/
3. Decide which commands should go where
1. In the CLI:
- `octopress scaffold`
- `octopress new`
- `octopress build -w -e ENV`
- `octopress serve -w -e ENV`
2. In the Rakefile:
- `rake deploy`
- All plugin tasks
# in the octopress CLI...
class Octopress::Installer
def config_folder
File.join(gem_source_dir, "configs", "")
end
def install_configs
FileUtils.cp_r config_folder, File.join(Dir.pwd, "config", plugin_slug)
end
def install
%w[configs].each do |thing|
send("install_#{thing}")
end
end
def type
manifest_yml.fetch('type') || "plugin"
end
def plugin_slug
type == "plugin" ? manifest_yml.fetch('slug') : "theme"
end
private
def manifest_yml
YAML.safe_load_file(File.join(gem_source_dir, "MANIFEST.yml")) || {}
end
end
# in the ADN plugin
class Adn::Installer < Octopress::Installer
def gem_source_dir
File.expand_path("../../", __FILE__)
end
end
# in the Octopress::Commands::Installer...
class Octopress::Commands::Installer
def self.process(args, options)
plugin_name = args[0]
begin
require "#{plugin_name}"
rescue LoadError
begin
if File.read("#{Octopress.root}/Gemfile").match(/gem ["']#{plugin_name}["']/)
Octopress.logger.info("Oops! Looks like you haven't installed the gem but you have it in your Gemfile. Running 'bundle install'...")
`bundle install`
require "#{plugin_name}"
else
raise LoadError
end
rescue LoadError
Octopress.logger.info("We could couldn't find the plugin '#{plugin_name}'.")
Octopress.logger.info("Make sure you add this to your Gemfile:\n")
Octopress.logger.info("gem '#{plugin_name}'\n")
Octopress.logger.info("Then run 'bundle install' and retry the installation.")
raise LoadError
end
end
# Essentially doing: 'Adn::Installer.new.install':
Class.const_get(classify(plugin_name)).const_get("Installer").new.install
end
end
task :test do
rm_r "test_site"
mkdir "test_site"
Dir.chdir("test_site") do
`octopress new .`
`echo -e "gem \"#{plugin_slug}\", path: \"#{File.expand_path('../../', __FILE__)}\"" > Gemfile`
`bundle install`
end
end
@imathis
Copy link

imathis commented Jun 9, 2013

Themes should not have plugin_slugs, they should be typed and the slug should always equal "theme".

@parkr
Copy link
Author

parkr commented Jun 9, 2013

User Workflow

$ # add plugin_name to Gemfile
$ octopress install plugin_name
# BOOM

Plugin author workflow

$ octopress scaffold plugin my-plugin-name
$ cd my-plugin-name
$ # edit MANIFEST.yml with plugin info
$ # add files
$ rake build
$ gem install -l pkg/my-plugin-name-0.0.1.gem
$ # test
$ rake release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment