From 53775bf8eff94cee40ed603a82df960c3c1bc9c1 Mon Sep 17 00:00:00 2001 From: Andrew Nesbitt Date: Fri, 12 Jan 2024 09:28:08 +0000 Subject: [PATCH] Add markdown action to ListsController and corresponding route --- app/controllers/lists_controller.rb | 5 +++++ app/views/lists/markdown.text.erb | 8 ++++++++ config/routes.rb | 6 +++++- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 app/views/lists/markdown.text.erb diff --git a/app/controllers/lists_controller.rb b/app/controllers/lists_controller.rb index 8591b88f..9819acfa 100644 --- a/app/controllers/lists_controller.rb +++ b/app/controllers/lists_controller.rb @@ -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 \ No newline at end of file diff --git a/app/views/lists/markdown.text.erb b/app/views/lists/markdown.text.erb new file mode 100644 index 00000000..73aba8e3 --- /dev/null +++ b/app/views/lists/markdown.text.erb @@ -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 %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index f3f0337b..f8046465 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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'