Skip to content
This repository has been archived by the owner on Dec 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #67 from connorshea/add-parent-feature-links
Browse files Browse the repository at this point in the history
Link to parent feature on feature page when relevant.
  • Loading branch information
connorshea committed May 15, 2018
2 parents 12ec66f + 409c2d7 commit 55d2835
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Use `friendly_id` gem for ease of use with slugs in URLs. ([#64])
- Introduce feature pages for each feature in the dataset. ([#64])
- Display subfeatures on feature pages when relevant. ([#66])
- Link to parent feature on feature page when relevant. ([#67])

### Changed
- Browser pages now have URLs like `/browsers/chrome` rather than `/browsers/1`. ([#62])
Expand Down Expand Up @@ -105,6 +106,7 @@ First tagged release, includes some basic functionality.
[#64]: https://github.com/connorshea/mdn-compat-data-explorer/pull/64
[#65]: https://github.com/connorshea/mdn-compat-data-explorer/pull/65
[#66]: https://github.com/connorshea/mdn-compat-data-explorer/pull/66
[#67]: https://github.com/connorshea/mdn-compat-data-explorer/pull/67

[Unreleased]: https://github.com/connorshea/mdn-compat-data-explorer/compare/v0.4.0...HEAD
[0.4.0]: https://github.com/connorshea/mdn-compat-data-explorer/compare/v0.3.1...v0.4.0
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/features_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ def show
@browsers = get_browsers

@subfeatures = Feature.where("name ~* ?", "^#{@feature.name}.*").where.not(slug: params[:slug])

parent_feature_name = @feature.name.split(/\./)
parent_feature_name.pop
parent_feature_name = parent_feature_name.join(".")
@parent_feature = Feature.find_by(name: parent_feature_name)
end

private
Expand Down
4 changes: 3 additions & 1 deletion app/views/features/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<div class="container">
<div class="row py-4">
<div class="col-12">
<% if @parent_feature %>
<p>Parent: <%= link_to @parent_feature.name, feature_path(@parent_feature.slug) %></p>
<% end %>
<h1><%= @feature.name %></h1>
</div>
</div>
Expand All @@ -23,5 +26,4 @@
</div>
</div>
<% end %>

</div>

0 comments on commit 55d2835

Please sign in to comment.