octopress에 대한 rakefile에 사용자 정의 배포 메소드를 만들었습니다.rakefile에서 공용 디렉토리에 액세스하는 방법
레이크 생성하고 내 공용 폴더의 모든 파일을 넣어 : 다음 (예 :/홈/제레미/웹 사이트/wwwdata) 내가 할 수 있도록하려면이 기능은
내가 할 수 있도록하려면, 간단 "rake compress"를 실행하고 출력 폴더의 파일 (모든 서버에 업로드 할 파일)에서 모든 여분의 공백과 빈 줄을 제거합니다.지금까지 나는이 있습니다
desc "compress output files"
task :compress do
puts "## Compressing html"
# read every .htm and .html in a directory
#TODO: Find this directory!
puts public_dir
Dir.glob("public_dir/**/*.{htm,html}").each do|ourfile|
linedata = ""
#open the file and parse it
File.open(ourfile).readlines.each do |line|
#remove excess spaces and carraige returns
line = line.gsub(/\s+/, " ").strip.delete("\n")
#append to long string
linedata << line
end
#reopen the file
compfile = open(ourfile, "w")
#write the compressed string to file
compfile.write(linedata)
#close the file
compfile.close
end
end
내가 그 출력 디렉토리를 찾는 데 문제. 나는 그것이 _config.yml에 지정되어 있고 rakefile에서 분명히 사용된다는 것을 알고 있지만, 어떤 변수도 사용하려고 할 때마다 작동하지 않습니다.
Google 검색을 통해 문서를 읽고 많이 찾지 못했습니다. 정보를 얻을 수있는 방법이 있습니까? 하드 코딩 된 파일 경로는 플러그인으로 제출하거나 다른 사람이 사용할 수 있도록 요청을 가져 오기 때문에 요청하기 때문에 필요하지 않습니다.
완벽하게 작동합니다 .. 감사합니다! –