Sha256: b5ef70e7a47dec3e975b56b4f73d8e0e207e5a1b6d698bd9fe19b134000e5a56

Contents?: true

Size: 1.49 KB

Versions: 7

Compression:

Stored size: 1.49 KB

Contents

class DiscourseTheme::Scaffold

  BLANK_FILES = %w{
    common/common.scss
    common/header.html
    common/after_header.html
    common/footer.html
    common/head_tag.html
    common/body_tag.html
    common/embedded.scss

    desktop/desktop.scss
    desktop/header.html
    desktop/after_header.html
    desktop/footer.html
    desktop/head_tag.html
    desktop/body_tag.html

    mobile/mobile.scss
    mobile/header.html
    mobile/after_header.html
    mobile/footer.html
    mobile/head_tag.html
    mobile/body_tag.html
  }

  ABOUT_JSON = <<~STR
    {
      "name": "#NAME#",
      "about_url": "URL",
      "license_url": "URL",
      "assets": {
      },
      "color_schemes": {
      }
    }
  STR

  HELP = <<~STR
    Are you a bit lost? Be sure to read https://meta.discourse.org/t/how-to-develop-custom-themes/60848
  STR

  GIT_IGNORE = <<~STR
    .discourse-site
    HELP
  STR

  def self.generate(dir)
    puts "Generating a scaffold theme at #{dir}"

    puts "What would you like to call your theme? "
    name = STDIN.gets.strip
    if name.length == 0
      puts "Please pick a name"
      exit 1
    end

    FileUtils.mkdir_p dir
    Dir.chdir dir do
      File.write('about.json', ABOUT_JSON.sub("#NAME#", name))
      File.write('HELP', HELP)
      File.write('.gitignore', GIT_IGNORE)

      BLANK_FILES.each do |f|
        puts "#{f}"
        FileUtils.mkdir_p File.dirname(f)
        FileUtils.touch f
      end

      puts "Initializing git repo"
      puts `git init .`
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
discourse_theme-0.1.6 lib/discourse_theme/scaffold.rb
discourse_theme-0.1.5 lib/discourse_theme/scaffold.rb
discourse_theme-0.1.4 lib/discourse_theme/scaffold.rb
discourse_theme-0.1.3 lib/discourse_theme/scaffold.rb
discourse_theme-0.1.2 lib/discourse_theme/scaffold.rb
discourse_theme-0.1.1 lib/discourse_theme/scaffold.rb
discourse_theme-0.1.0 lib/discourse_theme/scaffold.rb