Skip to content

Commit

Permalink
Add no_email and random_email features
Browse files Browse the repository at this point in the history
  • Loading branch information
cdainmiller committed Jun 27, 2019
1 parent 4ed5e26 commit ff0b978
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
12 changes: 11 additions & 1 deletion app/controllers/generator_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ def index
author: author,
explicit: explicit,
category: category,
type: type
type: type,
random_email: random_email,
no_email: no_email
}).generate!

SavedQuery.save_by(params)
Expand Down Expand Up @@ -61,4 +63,12 @@ def category
def type
params[:type] or NullType.new.type
end

def random_email
params[:random_email]
end

def no_email
params[:no_email]
end
end
13 changes: 12 additions & 1 deletion app/models/feed.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
class Feed
attr_accessor :existing_feed, :episodes, :duplicate_guid,
:empty_guid, :malformed_audio, :email, :type,
:title, :description, :author, :explicit, :category
:title, :description, :author, :explicit, :category,
:random_email, :no_email

def initialize options
@options = options
Expand All @@ -16,6 +17,8 @@ def generate!
render_explicit if @options[:explicit]
render_category if @options[:category]
render_type if @options[:type]
render_random_email if @options[:random_email]
render_no_email if @options[:no_email]
create_episodes if @options[:episodes]
self
end
Expand Down Expand Up @@ -72,4 +75,12 @@ def render_category
def render_type
self.type = @options[:type]
end

def render_random_email
self.random_email = "#{SecureRandom.hex}@gmail.com"
end

def render_no_email
self.no_email = @options[:no_email]
end
end
18 changes: 16 additions & 2 deletions app/views/feeds/_test_feed.xml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
<![CDATA[<p><%= @feed.description %></p>]]>
</description>

<managingEditor><%= @feed.email %></managingEditor>
<% if @feed.no_email %>
<% else %>
<% if @feed.random_email %>
<managingEditor><%= @feed.random_email %></managingEditor>
<% else %>
<managingEditor><%= @feed.email %></managingEditor>
<% end %>
<% end %>
<copyright><%= @feed.author %></copyright>
<generator>FeedIt.DEV</generator>

Expand All @@ -15,7 +22,14 @@

<itunes:owner>
<itunes:name><%= @feed.title %></itunes:name>
<itunes:email><%= @feed.email %></itunes:email>
<% if @feed.no_email %>
<% else %>
<% if @feed.random_email %>
<itunes:email><%= @feed.random_email %></itunes:email>
<% else %>
<itunes:email><%= @feed.email %></itunes:email>
<% end %>
<% end %>
</itunes:owner>

<itunes:author><%= @feed.author %></itunes:author>
Expand Down
12 changes: 9 additions & 3 deletions app/views/landing/xml.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@

<hr />

<h3><pre>existing_feed=true | <a href="https://app.feedit.dev/f?existing_feed=true">example</a></pre></h2>
<h3><pre>existing_feed=true | <a href="https://app.feedit.dev/f?existing_feed=true">example</a></pre></h3>
<p>This ignores all other attributes, and pulls in a random feed from iTunes</p>

<h3><pre>email=<input class="custom-email" /> | <a class="email-example" href="https://app.feedit.dev/f?existing_feed=true">example</a></pre></h2>
<h3><pre>email=<input class="custom-email" /> | <a class="email-example" href="https://app.feedit.dev/f?existing_feed=true">example</a></pre></h3>
<p>This renders the feed with the email you enter above. Enter your email, then click the example link.</p>

<div style="border: 1px #000 solid; margin-bottom: 20px;" /></div>
<h3><pre>random_email=true</pre></h3>
<p>This generates and sets a random email address, and should be used in place of the `email=` param.</p>

<h3><pre>no_email=true</pre></h3>
<p>This ignores all previous email attributes, and removes the email node from the feed, entirely.


<div style="border: 1px #000 solid; margin-bottom: 20px;" /></div>

<h1>Episode Options</h1>
<hr />

Expand Down

0 comments on commit ff0b978

Please sign in to comment.