Skip to content

Commit

Permalink
Add markdown action to ListsController and corresponding route
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Jan 12, 2024
1 parent d36940a commit 53775bf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/controllers/lists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ def index
def show
@list = List.find(params[:id])
end

def markdown
@lists = List.displayable.order(Arel.sql("(repository ->> 'stargazers_count')::text::integer").desc.nulls_last).all.select{|l| l.description.present? && !l.name.include?('?') }
render layout: false, content_type: 'text/plain'
end
end
8 changes: 8 additions & 0 deletions app/views/lists/markdown.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# The Ultimate Awesome List [![Awesome](https://awesome.re/badge-flat.svg)](https://awesome.re)
Every awesome list on every topic, including awesome lists of awesome lists.

This is list was generated automatically from [awesome.ecosyste.ms](https://awesome.ecosyste.ms/), an open API service indexing awesome lists of open source software. It includes every awesome list with at least 30 items and a description, sorted by most stars first.

<% @lists.each do |list| %>
<%= "- [#{list.name}](#{list.url}) - #{list.awesome_description}" %>
<% end %>
6 changes: 5 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
end
end

resources :lists
resources :lists do
collection do
get :markdown, defaults: { format: :text }
end
end

resources :exports, only: [:index], path: 'open-data'

Expand Down

0 comments on commit 53775bf

Please sign in to comment.