Skip to content

Commit

Permalink
Merge pull request #136 from basho/cleanups
Browse files Browse the repository at this point in the history
Add i18n and clean up config
  • Loading branch information
Brian Sparrow committed Dec 20, 2012
2 parents 5583fad + 143f652 commit 71ebfb3
Show file tree
Hide file tree
Showing 17 changed files with 149 additions and 159 deletions.
127 changes: 14 additions & 113 deletions config.rb
Original file line number Diff line number Diff line change
@@ -1,93 +1,22 @@
require 'aws/s3'
require 'versionomy'
require './lib/env'
require './lib/org'
require './lib/versionify'
require './lib/faqml'
require './lib/rocco'
require './lib/deploy'
require './lib/index'
require './lib/sitemap_render_override'
require './lib/duals'

if ENV['RIAK_VERSION'].blank? || ENV['RIAK_VERSION'] !~ /[\d\.]+/
versions = YAML::load(File.open('data/versions.yml'))
for proj, vs in versions['currents']
proj = proj.upcase
ENV["#{proj}_VERSION"] = vs
puts "#{proj}_VERSION=#{ENV["#{proj}_VERSION"]}"
end
end

$versions = {
:riak => ENV['RIAK_VERSION'].presence,
:riakcs => ENV['RIAKCS_VERSION'].presence || ENV['RIAK_VERSION'].presence,
:riakee => ENV['RIAKEE_VERSION'].presence || ENV['RIAK_VERSION'].presence
}

use Rack::Middleman::VersionRouter #if $versions[:riak].present?

# this is not optimal. Hook it into the "watch" mechanism
puts "== Generating API"
for api in Dir.glob("**/*.api")
r = Rocco.new(api, [], :language => 'bash', :template_file => './source/layouts/api.mustache') #{File.read(api)}
File.open(api.sub(/\.api$/, '.html.erb'), 'w') do |html|
html.write(r.to_html)
end
end
for api in Dir.glob("**/*.roc")
r = DocRocco.new(api, [], :language => 'bash', :template_file => './source/layouts/roc.mustache') #{File.read(api)}
File.open(api.sub(/\.roc$/, '.html.erb'), 'w') do |html|
html.write(r.to_html)
end
end

###
# Compass
###

# Susy grids in Compass
# First: gem install compass-susy-plugin
# require 'susy'

# Change Compass configuration
# compass_config do |config|
# config.output_style = :compact
# end

###
# Page options, layouts, aliases and proxies
###

# Per-page layout changes:
#
# With no layout
# page "/path/to/file.html", :layout => false
#
# With alternative layout
# page "/path/to/file.html", :layout => :otherlayout
#
# A path which all have the same layout
# with_layout :admin do
# page "/admin/*"
# end

page "/404.html", :directory_index => false
# since we're using ERB to dynamically generate this, MM assumes it's html
page "/js/standalone/version-bar.js", :proxy => "js/standalone/version-bar.html", :directory_index => false, :ignore => true
page "/404.html", :directory_index => false


# Proxy (fake) files
# page "/this-page-has-no-template.html", :proxy => "/template-file.html" do
# @which_fake_page = "Rendering a fake page with a variable"
# end

# page "/tutorials/*", :layout => 'layouts/layout'

# Register the FML plugin to middleman
Middleman::Application.register Middleman::Renderers::FAQML
# Middleman::Application.register Middleman::Renderers::Rocco


#############
# override tha languages to manage versions!?
%w{riak riakcs riakee}.each do |project|
version = $versions[project.to_sym]
page "/#{project}/#{version}/index.html", :proxy => "/#{project}-index.html", :directory_index => false, :ignore => true
end

def build_keyword_pages
keyword_pages = {}
Expand All @@ -110,14 +39,6 @@ def build_keyword_pages
end
end

# for api in Dir.glob("**/*.api")
# page api.sub(/\.?\/?source/, '').sub(/\.api$/, '.html'), :layout => false
# end

# for api in Dir.glob("**/*.roc")
# page api.sub(/\.?\/?source/, '').sub(/\.roc$/, '.html'), :layout => false
# end

if ENV.include?('INDEX')
puts "== Indexing"
build_yokozuna_index(sitemap.resources)
Expand Down Expand Up @@ -264,53 +185,33 @@ def build_nav(section, c_name='', depth=1)
# Automatic image dimensions on image_tag helper
# activate :automatic_image_sizes

# require 'rack/codehighlighter'
# require "pygments"
# use Rack::Codehighlighter,
# :pygments,
# :element => "pre>code",
# :pattern => /\A:::([-_+\w]+)\s*\n/,
# :markdown => true

# set language
set :css_dir, 'css'
set :js_dir, 'js'
set :images_dir, 'images'

set :markdown_engine, :redcarpet
set :markdown, :fenced_code_blocks => true,
:smartypants => true,
:tables => true,
:no_intra_emphasis => true,
:lax_html_blocks => true
# :autolink => true,
# :with_toc_data => true

use Rack::Middleman::VersionRouter

activate :faqml
activate :directory_indexes
activate :versionify

%w{riak riakcs riakee}.each do |project|
version = $versions[project.to_sym] || ENV['RIAK_VERSION']
page "/#{project}/#{version}/index.html", :proxy => "/#{project}-index.html", :directory_index => false, :ignore => true
end

activate :i18n
activate :cache_buster
activate :relative_assets

# Build-specific configuration
configure :build do
activate Middleman::Features::ProductionCheck

activate :production_check #Middleman::Features::ProductionCheck
activate :minify_css
activate :minify_javascript
# activate :gzip

# activate :cache_buster
# activate :relative_assets

# Compress PNGs after build
# require "middleman-smusher"
# activate :smusher

ignore "source/images/layout/*.png"

activate :version_dirs
Expand Down
1 change: 1 addition & 0 deletions data/global_nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ riak:
- title: "FAQs"
sub:
- "[[All FAQs|FAQs]]"
- "[[The Basics|Basic FAQs]]"
- "[[Developing on Riak|Developing on Riak FAQs]]"
- "[[Operating Riak|Operating Riak FAQs]]"
- "[[Log Messages|Log Messages FAQs]]"
Expand Down
2 changes: 2 additions & 0 deletions deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
exit(0)
end

ENV['RIAK_DOCS_LANG'] = 'en'

`rm -rf build`
ENV['RIAK_VERSION'] = ARGV[0]
ENV['RIAKCS_VERSION'] = ARGV[1] || ARGV[0]
Expand Down
2 changes: 2 additions & 0 deletions lib/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,5 @@ def registered(app)
end
end
end

::Middleman::Extensions.register(:production_check, ::Middleman::Features::ProductionCheck)
16 changes: 16 additions & 0 deletions lib/duals.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require './lib/rocco'

# this is not optimal. Hook it into the "watch" mechanism
puts "== Generating DUAL Pages"
for api in Dir.glob("**/*.api")
r = Rocco.new(api, [], :language => 'bash', :template_file => './source/layouts/api.mustache')
File.open(api.sub(/\.api$/, '.html.erb'), 'w') do |html|
html.write(r.to_html)
end
end
for api in Dir.glob("**/*.roc")
r = DocRocco.new(api, [], :language => 'bash', :template_file => './source/layouts/roc.mustache')
File.open(api.sub(/\.roc$/, '.html.erb'), 'w') do |html|
html.write(r.to_html)
end
end
18 changes: 18 additions & 0 deletions lib/env.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
LANGUAGE = (ENV['RIAK_DOCS_LANG'] || 'en').to_sym
puts "RIAK_DOCS_LANG=#{LANGUAGE}"
I18n.locale = I18n.default_locale = LANGUAGE

if ENV['RIAK_VERSION'].blank? || ENV['RIAK_VERSION'] !~ /[\d\.]+/
versions = YAML::load(File.open('data/versions.yml'))
for proj, vs in versions['currents']
proj = proj.upcase
ENV["#{proj}_VERSION"] = vs
puts "#{proj}_VERSION=#{ENV["#{proj}_VERSION"]}"
end
end

$versions = {
:riak => ENV['RIAK_VERSION'].presence,
:riakcs => ENV['RIAKCS_VERSION'].presence || ENV['RIAK_VERSION'].presence,
:riakee => ENV['RIAKEE_VERSION'].presence || ENV['RIAK_VERSION'].presence
}
33 changes: 17 additions & 16 deletions lib/faqml.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@

module Middleman::Renderers::FAQML
def registered(app)
# FAQML is not included in the default gems,
# but we'll support it if available.
begin
# Load gem
require "faqml"

app.before_configuration do
template_extensions :fml => :html
class << self
def registered(app)
begin
require "faqml"
app.before_configuration do
template_extensions :fml => :html
end
# Setup FAQML options to work with partials
::FAQML::Engine.set_default_options(
:buffer => '@_out_buf',
:generator => ::Temple::Generators::StringBuffer
)
rescue LoadError
puts "Error Loading FAQML"
end

# Setup FAQML options to work with partials
::FAQML::Engine.set_default_options(
:buffer => '@_out_buf',
:generator => ::Temple::Generators::StringBuffer
)
rescue LoadError
end
alias :included :registered
end
end

::Middleman::Extensions.register(:faqml, Middleman::Renderers::FAQML)
27 changes: 27 additions & 0 deletions locales/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
en:
basho: Basho
visit_basho: Visit Basho
home: Home
riak_docs: Riak Docs
tagline: "Product tutorials, how-tos, and fully-documented APIs."
keywords: Keywords
navigation: Navigation
all_projects: All Riak Projects
docs_on_github: "These docs are available on GitHub. Please submit ideas and patches."
secondary_header: "These May Also Interest You"
faqs_link: "[[FAQs]]"
apis_link: "[[APIs]]"
tutorial_nav: "Tutorial Nav"
previous: Prev
next: Next
toc_contents: Contents
footer: "This work is licensed under a <a href=\"http://creativecommons.org/licenses/by/3.0/\" target=\"_blank\">Creative Commons Attribution 3.0 Unported License</a>"
riak_cs:
info:
title: Riak CS Only
body: "To try out Riak CS, sign up for a <a href=\"http://info.basho.com/RiakCS1.1_DeveloperTrialRequest.html\">developer trial</a>."
riak_ee:
info:
title: Riak Enterprise Only
body: "This documentation applies only to Riak Enterprise, Basho's commercial extension to [[Riak]]. To talk to us about using Riak Enterprise, <a href=\"http://info.basho.com/Wiki_Contact.html\">let us know</a>."
27 changes: 27 additions & 0 deletions locales/jp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
jp:
basho: Bashosan
visit_basho: Visit Bashosan
home: Home
riak_docs: Riak Docs
tagline: "Product tutorials, how-tos, and fully-documented APIs."
keywords: Keywords
navigation: Navigation
all_projects: All Riak Projects
docs_on_github: "These docs are available on GitHub. Please submit ideas and patches."
secondary_header: "These May Also Interest You"
faqs_link: "[[FAQs]]"
apis_link: "[[APIs]]"
tutorial_nav: "Tutorial Nav"
previous: Prev
next: Next
toc_contents: Contents
footer: "This work is licensed under a <a href=\"http://creativecommons.org/licenses/by/3.0/\" target=\"_blank\">Creative Commons Attribution 3.0 Unported License</a>"
riak_cs:
info:
title: Riak CS Only
body: "To try out Riak CS, sign up for a <a href=\"http://info.basho.com/RiakCS1.1_DeveloperTrialRequest.html\">developer trial</a>."
riak_ee:
info:
title: Riak Enterprise Only
body: "This documentation applies only to Riak Enterprise, Basho's commercial extension to [[Riak]]. To talk to us about using Riak Enterprise, <a href=\"http://info.basho.com/Wiki_Contact.html\">let us know</a>."
3 changes: 1 addition & 2 deletions source/css/common.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,7 @@ div[role="main"] {
.logo {
margin-top : 5px;
@include size(200px, 33px);
// Deprecated behavior, but what other options do we have?
@include layout-sprite(logo2);
background: url(../images/layout/logo2.png)
}
}

Expand Down
6 changes: 2 additions & 4 deletions source/layouts/_footer.slim
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
footer.mastfooter
| This work is licensed under a
a href="http://creativecommons.org/licenses/by/3.0/" target="_blank"
| Creative Commons Attribution 3.0 Unported License
== I18n.t(:footer)
br
| Copyright &copy; #{Date.today.year} Basho Technologies, Inc. All rights reserved.
| &copy; 2011-#{Date.today.year} Basho Technologies, Inc.
8 changes: 4 additions & 4 deletions source/layouts/_header.slim
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ header.masthead
div#top-nav
form action="http://search.basho.com"
input#main-search size="5" type="search" placeholder="Search" name="q"
a href="/index.html" Home
a href="http://www.basho.com" Basho
a href="/index.html"== I18n.t(:home)
a href="http://www.basho.com"== I18n.t(:basho)
a.responsive-toggle
a.logo href="/index.html"
h1 Riak Docs
span.tagline Product tutorials, how-tos, and fully-documented APIs.
h1== I18n.t(:riak_docs)
span.tagline== I18n.t(:tagline)
img.shadow-divider(src="/images/layout/shadow-divider.png")
2 changes: 1 addition & 1 deletion source/layouts/_keywords.slim
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
- if data.page.keywords.present?
h4 Keywords
h4== I18n.t(:keywords)
== data.page.keywords.map{|kw| "<a href=\"/keywords/"+kw+"/\">"+kw+"</a>"}.join(', ')
11 changes: 5 additions & 6 deletions source/layouts/_primary.slim
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
aside#nav-container role="complementary"
nav.overview#primary-nav role="nav"
h2.responsive-link
| Navigation
== I18n.t(:navigation)
a.responsive-toggle
h3.responsive-link.visit-basho
a href="http://www.basho.com" Visit Basho
a href="http://www.basho.com"== I18n.t(:visit_basho)
h3.responsive-link
a href="/index.html" All Riak Projects
a href="/index.html"== I18n.t(:all_projects)
- project = data.page.project || 'riak'
- data.global_nav[project].each do |section|
- add_class = section['class'] || ''
- nav_data, active = build_nav(section['sub'], add_class)
h3(class=(active ? "active #{add_class}" : add_class))
span==section['title']
==nav_data

.submissions-note
a(href='https://github.com/basho/basho_docs' target='_blank')
| These docs are available on GitHub. Please submit ideas and patches.
a href='https://github.com/basho/basho_docs' target='_blank'
== I18n.t(:docs_on_github)
Loading

0 comments on commit 71ebfb3

Please sign in to comment.