Skip to content

Commit

Permalink
Changes to Hammer navigation, adds correct aria label, and allows nav…
Browse files Browse the repository at this point in the history
… bar to be turned on and off. Closes #65 Closes #64
  • Loading branch information
Steven Spriggs committed Mar 20, 2019
1 parent cbb545d commit fd2bdec
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ $RECYCLE.BIN/
# SublimeText project files
*.sublime-workspace

tmp/
vendor/

.bundle/
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ GEM
tzinfo (1.2.2)
thread_safe (~> 0.1)
wannabe_bool (0.6.0)
webrick (1.3.1)
webrick (1.4.2)

PLATFORMS
ruby
Expand Down
6 changes: 3 additions & 3 deletions hammer/data/mock_data.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
hammer_nav:
disabled: false

shared_themes:
"Code":
"layouts/masthead--v1": "code"
"layouts/footer__contact--v1": "code"
"layouts/footer__credits--v2": "code"
"layouts/footer__icons--v2": "code"
"layouts/browser-update-org--v2": "code"
"Some Other Theme":
"some/other/path/template": "theme-folder-name"
"another/path/template": "theme-folder-name"

show_editable_regions: false #If true a div with `border: 1px dashed red` will be injected into the content of the region

Expand Down
23 changes: 23 additions & 0 deletions hammer/services/mock_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,29 @@ def self.load(theme_root, request_path)

YAML.set_file_root(theme_root)

# # Deep Merging of yml files using map reduce
# yml_files = []
# # Load default mock data
# yml << Pathname.new(File.dirname(__FILE__)+'/../data/mock_data.yml')
#
# # Load Theme Root mock_data.yml
# theme_root_yml = theme_root.join(Pathname.new('mock_data.yml'))
# if theme_root_yml
# yml_files << theme_root_yml
# end
#
# # Load Template YAML files
# template_yml = theme_root.join('data',Pathname.new(File.basename(request_path, ".html")+".yml"))
# old_path_template_yml = theme_root.join(Pathname.new(File.basename(request_path, ".html")+".yml"))
# if template_yml.exist?
# yml_files << template_yml
# elseif old_path_template_yml.exist?
# yml_files << old_path_template_yml
# end
# TODO: Parse new yml
# combined_yml = yml_files.map{ |file| YAML.load_file(file) }.reduce( {}, :deep_merge!)
# TODO: Erb parse new combined YML

if theme_root
yml_path = theme_root.join(Pathname.new('mock_data.yml'))
if yml_path.exist?
Expand Down
6 changes: 6 additions & 0 deletions hammer/services/tags/basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ class Basic < TagContainer
output.join("")
end

tag 'hammer_nav' do |tag|
if !tag.globals.context.data['hammer_nav'] || !tag.globals.context.data['hammer_nav']['disabled']
tag.expand
end
end

# Renders an unordered list (<ul>) of HTML links to the pages leading to the current page. If the 'text_only'
# attribute is 'true', then instead of a list of HTML links, a plain text list will be rendered with the
# value of the 'separator' attribute used to separate each item. The default separator is ' | '.
Expand Down
18 changes: 15 additions & 3 deletions hammer/services/theme_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,13 @@ def render_with_radius
@htmldoc = Nokogiri::HTML::Document.parse(html)

output = insert_meta_tags
output = insert_hammer_nav
output = insert_style_tags

if self.data_errors
output = insert_errors_tags
end
output = insert_style_tags

if self.data && self.data['page'] && self.data['page']['javascript']
output = insert_javascript_tags
end
Expand All @@ -159,13 +162,22 @@ def insert_meta_tags
end
end

def insert_style_tags
def insert_hammer_nav
begin
# @htmldoc = Nokogiri::HTML::Document.parse(output)
hammer_nav_content
hammer_nav = radius_parser.parse(self.hammer_nav_content)

@htmldoc.at('body').children.first.before(hammer_nav)
@htmldoc.to_html
rescue => e
Hammer.error "Could not insert Hammer nav into your body tag may not exist. #{e}"
end
end

def insert_style_tags
begin
# @htmldoc = Nokogiri::HTML::Document.parse(output)

css_file_src = Pathname.new(File.expand_path File.dirname(__FILE__)+"/../css/wvu-hammer-inject.css").read
css_file = "<style>"+css_file_src+"</style>"
@htmldoc.at('head').add_child(css_file)
Expand Down
14 changes: 8 additions & 6 deletions hammer/views/_hammer_nav.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<nav id="wvu-hammer-nav" aria-label="Breadcrumbs" class="wvu-hammer-breadcrumbs">
<div class="wvu-hammer-breadcrumbs__container">
<h1>Hammer</h1>
<r:hammer_breadcrumbs style="" />
</div>
</nav>
<r:hammer_nav>
<nav id="wvu-hammer-nav" aria-label="Hammer Breadcrumbs" class="wvu-hammer-breadcrumbs">
<div class="wvu-hammer-breadcrumbs__container">
<h1>Hammer</h1>
<r:hammer_breadcrumbs style="" />
</div>
</nav>
</r:hammer_nav>

0 comments on commit fd2bdec

Please sign in to comment.