forked from asciidoctor/asciidoctor.org
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial Awestruct-based site and build
- Loading branch information
1 parent
15c55c6
commit 9e56441
Showing
50 changed files
with
19,350 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
README.adoc | ||
Gemfile | ||
Gemfile.lock | ||
Rakefile | ||
publish | ||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
/Gemfile.lock | ||
/_site/ | ||
/.awestruct/ | ||
/.sass-cache/ | ||
/_tmp/ | ||
Gemfile.lock | ||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rvm use 1.9.3@awestruct-site --create |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
language: ruby | ||
rvm: | ||
- 1.9.3 | ||
# - 2.0.0 | ||
env: | ||
global: | ||
secure: "bc8N2hVcc1Sl5Bs2Y+EDYiazosWzOTC68fWM5BToBuXSNjukYxbeOngKTsCN\nVGiKxEy2+1Wsf+YDV0Y2Z/TibFT7FHq+qXvniZLWLJOsXZJT3MR8SbbzW3dt\nClWN+4ypIgwE42nnQ+sH9F8Fvib8xzN0/UKoH6ppntAv6yfSnIc=" | ||
branches: | ||
only: | ||
- develop | ||
script: rake travis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
asciidoctor.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This is a bundler configuration file (http://gembundler.com). | ||
# | ||
# Bundler makes it easy to make sure that your application has the dependencies | ||
# it needs to start up and run without errors. It locates and installs the gems | ||
# and their dependencies listed in this file, Gemfile. | ||
# | ||
# After installing any needed gems to your system, bundler writes a snapshot of | ||
# all of the gems and versions that it installed to Gemfile.lock. | ||
# | ||
# Gemfile.lock makes your application a single package of both your own code | ||
# and the third-party code so it remains stable in a known working state. | ||
|
||
source 'https://rubygems.org' | ||
|
||
gem 'awestruct', '0.5.0.cr' | ||
#gem 'awestruct', :git => 'git://github.com/awestruct/awestruct.git', :branch => 'master' | ||
#gem 'awestruct', :git => 'git://github.com/mojavelinux/awestruct.git', :branch => 'integrate' | ||
gem 'asciidoctor', '0.1.1' | ||
gem 'erubis', '2.7.0' | ||
gem 'haml', '3.1.8' | ||
gem 'slim', '2.0.0.pre.6' | ||
gem 'zurb-foundation' | ||
gem 'jruby-openssl', '0.7.7', :platforms => :jruby | ||
gem 'rb-inotify', '0.8.8', :platforms => [:ruby, :jruby] | ||
gem 'tzinfo', '0.3.35' | ||
gem 'uglifier', '1.3.0' | ||
gem 'htmlcompressor', '0.0.3' | ||
gem 'git', '1.2.5', :group => :test | ||
gem 'rake', '10.0.3', :group => :test | ||
gem 'rdoc', '4.0.0', :group => :test | ||
gem 'tomdoc', '0.2.5', :group => :test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
= asciidoctor.org image:https://secure.travis-ci.org/asciidoctor/asciidoctor.github.com.png?branch=develop["Build Status", link="https://travis-ci.org/asciidoctor/asciidoctor.github.com"] | ||
|
||
Project site for http://asciidoctor.org[Asciidoctor], baked with Awestruct and published by Travis CI. | ||
|
||
For instructions on how to install Awestruct and its dependencies, refer to the section xref:install-awestruct[Install Awestruct] below. | ||
|
||
== Preview the site locally | ||
|
||
To preview the site locally, simply run the default rake build task: | ||
|
||
rake | ||
|
||
The default rake build task is +preview+, so you're effectively typing: | ||
|
||
rake preview | ||
|
||
The +preview+ task is just a short way of invoking Awestruct in development mode directly: | ||
|
||
awestruct -d | ||
|
||
Now visit http://localhost:4242 to preview the site. | ||
|
||
To rebuild the site from a clean state, pass the +--force+ flag to the +preview+ task: | ||
|
||
rake preview[--force] | ||
|
||
You can pass any flag through to Awestruct using the syntax in the previous command. | ||
|
||
If you just want to generate the site, run: | ||
|
||
rake gen | ||
|
||
=== Set the JavaScript runtime | ||
|
||
If you're building the site on Linux and Awestruct fails to locate a JavaScript runtime, you can either: | ||
|
||
. install a node.js package or | ||
. set the following environment variable in your shell profile scripts (e.g., +~/.bash_profile+): | ||
|
||
export EXECJS_RUNTIME=SpiderMonkey | ||
|
||
== Add and commit files | ||
|
||
Add new files (such as a new blog entry or image): | ||
|
||
git add news/news-slug.adoc | ||
|
||
or all new files present in a directory (it only affects new files, skips files already committed) | ||
|
||
git add news/ | ||
|
||
Commit all files marked to be committed, including new files that were just added: | ||
|
||
git commit -m 'your message here' | ||
|
||
Commit all files that have changed, even if not marked to be committed: | ||
|
||
git commit -a -m 'your message here' | ||
|
||
Make sure there are no files that are "untracked" or "modified": | ||
|
||
git status | ||
|
||
You should see: | ||
|
||
nothing to commit (working directory clean) | ||
|
||
Now you are ready to deploy. | ||
|
||
== Deploy the site to GitHub Pages | ||
|
||
The following commands will push changes (+git push+), clean build the site (+--force -g+) using the production profile (+-P production+), then deploy it to github pages (+--deploy+): | ||
|
||
git push | ||
awestruct -P production --force -g --deploy | ||
|
||
Or simply run the prepared rake build task (to deploy locally): | ||
|
||
rake deploy | ||
|
||
Or just push and let https://travis-ci.org/asciidoctor/asciidoctor.github.com[Travis CI] do the work of deploying the site: | ||
|
||
rake push | ||
|
||
If you want to push without triggering a publish, add the following to the commit message: | ||
|
||
[ci skip] | ||
|
||
== Install Awestruct | ||
|
||
First, install http://rvm.io[RVM]. Trust me on this. | ||
|
||
$ curl -#L https://get.rvm.io | bash -s stable --ruby | ||
|
||
Next, setup an RVM gemset for working with the Asciidoctor site: | ||
|
||
$ rvm use 1.9.3@asciidoctor-site --create | ||
|
||
At this point, you could install Awestruct directly, but since the site build has some additional dependencies, it's best to let bundler handle the installation. Bundler will also ensure that you are using the correct versions of each gem when you run Awestruct. | ||
|
||
$ bundle install | ||
|
||
You're now Awestruct! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
require 'rubygems' | ||
|
||
task :default => :preview | ||
|
||
desc 'Preview the site locally in development mode' | ||
task :preview, [:flags] do |t, args| | ||
cmd = 'bundle exec awestruct -d' | ||
if (args[:flags]) | ||
cmd = "#{cmd} #{args[:flags]}" | ||
end | ||
system cmd | ||
end | ||
|
||
desc 'Generate the site using the development profile' | ||
task :gen, [:flags] do |t, args| | ||
cmd = 'bundle exec awestruct -P development -g' | ||
if (args[:flags]) | ||
cmd = "#{cmd} #{args[:flags]}" | ||
end | ||
system cmd | ||
end | ||
|
||
desc 'Push local commits to origin/develop' | ||
task :push do | ||
system 'git push origin develop' | ||
end | ||
|
||
desc 'Generate and publish site to production (GitHub Pages) from home' | ||
task :deploy => :push do | ||
system 'bundle exec awestruct -P production --force -g' | ||
gen_rdoc | ||
system 'bundle exec awestruct -P production --deploy' | ||
end | ||
|
||
desc 'Generate site from Travis CI and, if not a pull request, publish site to production (GitHub Pages)' | ||
task :travis do | ||
# if this is a pull request, do a simple build of the site and stop | ||
if ENV['TRAVIS_PULL_REQUEST'] == '1' || ENV['TRAVIS_PULL_REQUEST'] == 'true' | ||
system 'bundle exec awestruct -P production -g' | ||
next | ||
end | ||
|
||
require 'yaml' | ||
require 'fileutils' | ||
|
||
# TODO use the Git library for these commands rather than system | ||
repo = %x(git config remote.origin.url).gsub(/^git:/, 'https:') | ||
system "git remote set-url --push origin #{repo}" | ||
system 'git remote set-branches --add origin master' | ||
system 'git fetch -q' | ||
system "git config user.name '#{ENV['GIT_NAME']}'" | ||
system "git config user.email '#{ENV['GIT_EMAIL']}'" | ||
system 'git config credential.helper "store --file=.git/credentials"' | ||
# CREDENTIALS assigned by a Travis CI Secure Environment Variable | ||
# see http://about.travis-ci.org/docs/user/build-configuration/#Secure-environment-variables for details | ||
File.open('.git/credentials', 'w') {|f| f.write("https://#{ENV['GH_TOKEN']}:@github.com") } | ||
set_pub_dates 'develop' | ||
system 'git branch master origin/master' | ||
system 'bundle exec awestruct -P production -g' | ||
gen_rdoc | ||
system 'bundle exec awestruct -P production --deploy' | ||
File.delete '.git/credentials' | ||
end | ||
|
||
desc "Assign publish dates to news entries" | ||
task :setpub do | ||
set_pub_dates 'develop' | ||
end | ||
|
||
def gen_rdoc | ||
require 'fileutils' | ||
asciidoctor_dir = %x(bundle show asciidoctor).chomp | ||
asciidoctor_ver = asciidoctor_dir.split('-').last | ||
system %(rdoc -m README.asciidoc -t "API Documentation for Asciidoctor #{asciidoctor_ver}" --markup tomdoc -o rdoc README.* lib), :chdir => asciidoctor_dir | ||
FileUtils.mv "#{asciidoctor_dir}/rdoc", '_site/rdoc' | ||
end | ||
|
||
def set_pub_dates(branch) | ||
require 'tzinfo' | ||
require 'git' | ||
local_tz = IO.readlines('_config/site.yml').find {|l| l.start_with?('local_tz: ') }.chomp.sub('local_tz: ', '') | ||
local_tz = TZInfo::Timezone.get(local_tz) | ||
|
||
repo = nil | ||
|
||
Dir['news/*.adoc'].select {|e| !e.start_with? 'news/_'}.each do |e| | ||
lines = IO.readlines e | ||
header = lines.inject([]) {|collector, l| | ||
break collector if l.chomp.empty? | ||
collector << l | ||
collector | ||
} | ||
|
||
do_commit = false | ||
if !header.detect {|l| l.start_with?(':revdate: ') || l.start_with?(':awestruct-draft:') || l.start_with?(':awestruct-layout:') } | ||
revdate = Time.now.utc.getlocal(local_tz.current_period.utc_total_offset) | ||
lines[2] = "#{revdate.strftime('%Y-%m-%d')}\n" | ||
lines.insert(3, ":revdate: #{revdate}\n") | ||
File.open(e, 'w') {|f| | ||
f.write(lines.join) | ||
} | ||
if !repo | ||
repo = Git.open('.') | ||
b = repo.branch(branch) | ||
b.remote = 'origin/develop' | ||
b.create | ||
b.checkout | ||
end | ||
repo.add(e) | ||
repo.commit "Set publish date of post #{e}" | ||
do_commit = true | ||
end | ||
|
||
if do_commit | ||
repo.push('origin', branch) | ||
end | ||
end | ||
end |
Oops, something went wrong.