GithubHelp home page GithubHelp logo

Export files to html about serve HOT 6 CLOSED

jlong avatar jlong commented on September 16, 2024
Export files to html

from serve.

Comments (6)

jlong avatar jlong commented on September 16, 2024

I'm interested in this feature, but it's currently not implemented. There are other engines that do this kind of thing though. Nanoc is an example: http://nanoc.stoneship.org/

from serve.

pauld avatar pauld commented on September 16, 2024

This would be a great feature. I've been a part of many projects where haml is not wanted beyond the prototype stage. A full export would allow mockups in haml, without having to sell the rest of the team on the somewhat tedious task of converting new versions of each page to html as the app progresses.

from serve.

mitchellfyi avatar mitchellfyi commented on September 16, 2024

staticmatic have a nice build module that could do most of the work... http://github.com/staticmatic/staticmatic/blob/master/lib/staticmatic/mixins/build.rb

from serve.

jlong avatar jlong commented on September 16, 2024

It would work for Haml, but Serve handles ERB and other formats as well.

from serve.

heikki avatar heikki commented on September 16, 2024

I wrote a rake task for exporting a static version.

It copies the static assets and loads from the serve those sass and haml files that don't start with underscore and saves them as css and html files. If links point to regular css and html files, they work in both static and dynamic versions.

Note that your folder structure might be different.

require 'ftools'
require 'open-uri'

site_root = 'http://localhost:4000/'
output_dir = 'deploy/'

desc "Spider the site #{site_root} and save the files under #{output_dir}"
task :spider do
  FileUtils.rm_rf(Dir.glob("#{output_dir}*"))
  files_to_copy = Dir.glob("public/**/[^_]*.{gif,png,jpg,css,js,ico,html}")
  files_to_copy.each do |path|
    save_path = output_dir + path.gsub(/^public\//, "")
    FileUtils.mkdir_p(File.dirname(save_path))
    File.copy(path, save_path, true)
  end
  files_to_spider = []
  files_to_spider += Dir.glob("views/**/[^_]*.html.haml").map{|f|f.gsub(/^views\//, "").gsub(".haml", "")}
  files_to_spider += Dir.glob("stylesheets/**/[^_]*.sass").map{|f|f.gsub(".sass", ".css")}
  files_to_spider.each do |path|
    save_path = output_dir + path
    puts "#{path} -> #{output_dir + path}"
    FileUtils.mkdir_p(File.dirname(save_path))
    open(site_root + path, 'rb') do |input|
      File.open(save_path, 'wb') do |output|
        output.write(input.read)
      end
    end
  end
end

from serve.

tors avatar tors commented on September 16, 2024

plus 1 for this feature!

from serve.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.