| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6cdc2ed commit 87ae510
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,17 +1,23 @@ | |||
| 1 | - [ | ||
| 2 | - <% if @config[:audience] %> | ||
| 3 | - <% @preface = "/enterprise/#{@config[:audience]}" %> | ||
| 4 | - <% end %> | ||
| 5 | - <% @items.select { |item| !item.attributes[:hide_from_search] }.each do |item| %> | ||
| 6 | - <% next if item[:filename].nil? || !item[:filename].end_with?('.md') %> | ||
| 7 | - <% @path = item[:filename].split('/')[1..-1].join('/')[0..-4] %> | ||
| 8 | - <% @path.chomp!('/index') if @path.end_with?('/index') %> | ||
| 9 | - { | ||
| 10 | - "title": "<%= clean_for_json(item[:title]) %>", | ||
| 11 | - <%# Split off the directory name, join, then remove the '.md' extension %> | ||
| 12 | - "url": "<%= @preface %>/<%= @path %>/", | ||
| 13 | - "body": "<%= clean_for_json(item.compiled_content) %>" | ||
| 14 | - }, | ||
| 15 | - <% end %> | ||
| 16 | - {} | ||
| 17 | - ] | ||
| 1 | + <% | ||
| 2 | + #build the JSON tree | ||
| 3 | + if @config[:audience] | ||
| 4 | + @preface = "/enterprise/#{@config[:audience]}" | ||
| 5 | + end | ||
| 6 | + @output = [] | ||
| 7 | + @items.select { |item| !item.attributes[:hide_from_search] }.each do |item| | ||
| 8 | + next if item[:filename].nil? || !item[:filename].end_with?('.md') | ||
| 9 | + @path = item[:filename].split('/')[1..-1].join('/')[0..-4] | ||
| 10 | + @path.chomp!('/index') if @path.end_with?('/index') | ||
| 11 | + | ||
| 12 | + @output.push({ | ||
| 13 | + :title => "#{clean_for_json(item[:title])}", | ||
| 14 | + :url => "#{@preface}/#{@path}/", | ||
| 15 | + :body => "#{clean_for_json(item.compiled_content)}" | ||
| 16 | + }) | ||
| 17 | + end | ||
| 18 | + %> | ||
| 19 | + <%= | ||
| 20 | + #output the generated tree | ||
| 21 | + # TODO JSON.generate() always/on production builds? | ||
| 22 | + JSON.pretty_generate(@output.sort{|a, b| a[:title] <=> b[:title]}) | ||
| 23 | + %> | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments