Adds form

This commit is contained in:
Nemo 2018-06-01 01:43:09 +05:30
parent e6e087655d
commit 292f455cb0
3 changed files with 59 additions and 2 deletions

View File

@ -1,3 +1,7 @@
# opml-gen # opml-gen
Simple web tool to generate OPML files to let you use RSS feeds everywhere Simple web tool to generate OPML files to let you use RSS feeds everywhere
Currently only support GitHub Starred Repos: It generates an OPML file so you can follow all of your starred repos easily.
I plan to add more OPML generators: GoodReads feed perhaps?

20
app.rb
View File

@ -1,5 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'dotenv/load' require 'dotenv'
require 'sinatra/base' require 'sinatra/base'
require 'sinatra/reloader' require 'sinatra/reloader'
require 'octokit' require 'octokit'
@ -13,7 +13,9 @@ class MyApp < Sinatra::Base
configure :development do configure :development do
register Sinatra::Reloader register Sinatra::Reloader
also_reload 'opml.rb' also_reload 'opml.rb'
Dotenv.load
end end
configure do configure do
set :r, Redis.new set :r, Redis.new
set :client, Octokit::Client.new( set :client, Octokit::Client.new(
@ -44,12 +46,26 @@ class MyApp < Sinatra::Base
[repos, time] [repos, time]
end end
get '/' do
File.read File.join 'public', 'index.html'
end
post '/submit/:type' do
if params[:type] == 'github'
username = params[:username]
redirect "/github/#{username}/starred.opml"
else
"Invalid Type"
end
end
get '/github/:user/starred.opml' do get '/github/:user/starred.opml' do
user = params[:user] user = params[:user]
repos, time = get_starred_repos_from_cache(user) repos, time = get_starred_repos_from_cache(user)
opml = OPML.new do opml = OPML.new do
@title = "Releases: #{user}/starred" @title = "Releases: #{user}/starred"
@date_created = Time.new(time.to_i).rfc822 # TODO: Fix this
@date_created = Time.now.rfc822
@date_modified = Time.now.rfc822 @date_modified = Time.now.rfc822
@owner_name = user @owner_name = user
end end

37
public/index.html Normal file
View File

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>opml-gen</title>
<link rel="stylesheet" href="https://cdn.rawgit.com/oxalorg/sakura/master/css/sakura-dark.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h1>opml-gen</h1>
<p>Generate <a href="https://feedly.com/i/cortex">OPML Files</a> for easy use</p>
<section>
<article>
<h2>GitHub/Starred</h2>
<p>Generate an OPML file for your starred repositories on GitHub</p>
<form method="post" action="/submit/github">
<label for="username">GitHub Username: </label>
<input type="text" name="username" placeholder="kelseyhightower">
<input type="submit" value="Get OPML!">
</form>
</article>
</section>
<!-- <section> -->
<article>
<h2>Why?</h2>
<p>GitHub publishes an RSS feed for releases for every repository. I've been trying to switch things to RSS, and <a href="https://github.com/isaacs/github/issues/410">Release Notifications</a> on GitHub is a very big pain point. This solves the problem by using your trusty RSS feed reader application instead of it's own thing.</p>
<p>You should also check out <a href="https://www.kill-the-newsletter.com/">kill-the-newsletter</a> for a similar solution with newsletters.
<p><abbr title="Outline Processor Markup Language">OPML</abbr> is a common format used to share lists of RSS feeds that you can import in your RSS application</abbr></p>
</article>
<!-- </section> -->
<footer>
<br><br>
Made with <a href="https://github.com/captn3m0/opml-gen">🤖</a> by <a href="https://captnemo.in">Nemo</a>
</footer>
</body>
</html>