Skip to content

Commit

Permalink
example app is setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg committed Jul 27, 2010
1 parent 3500015 commit 46832da
Show file tree
Hide file tree
Showing 17 changed files with 186 additions and 278 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,3 +1,4 @@
.DS_Store
log/*
tmp/*/*
tmp/*/*
db/*.sqlite3
16 changes: 16 additions & 0 deletions app/controllers/welcome_controller.rb
@@ -0,0 +1,16 @@
class WelcomeController < ApplicationController

def index
@api_key = PostageApp.config.api_key
@api_key = nil if @api_key.blank? || @api_key == 'PROJECT_API_KEY'

@subject = params[:subject] || 'Hello {{name}}'
@to = params[:to] || 'me@example.com'
@variable = params[:variable] || 'Tester'
@html = params[:html] || "<h1>Hi, {{name}}</h1>\n<p>This is a test.</p>"
@text = params[:text] || "Hi, {{name}}\nThis is a test."

@response = Mailer.deliver_message(params) if request.post?
end

end
2 changes: 2 additions & 0 deletions app/helpers/welcome_helper.rb
@@ -0,0 +1,2 @@
module WelcomeHelper
end
13 changes: 13 additions & 0 deletions app/models/mailer.rb
@@ -0,0 +1,13 @@
require 'postageapp/mailer'

class Mailer < PostageApp::Mailer

def message(params)
headers 'Reply-To' => 'sender@examlple.com'
subject params[:subject]
recipients params[:to] => { 'name' => params[:variable] }
from 'sender@example.com'
body :text_content => params[:text], :html_content => params[:html]
end

end
25 changes: 25 additions & 0 deletions app/views/layouts/application.html.erb
@@ -0,0 +1,25 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<%= stylesheet_link_tag 'style' %>
<title>Ruby on Rails 2 Example Application for PostageApp</title>
</head>

<body>
<div class='body_wrapper'>
<h1>
Ruby on Rails 2 Example Application for PostageApp
</h1>

<%= yield %>

<ul>
<li><a href='http://postageapp.com'>PostageApp</a></li>
<li><a href='http://github.com/theworkinggroup/postageapp-gem'>PostageApp Ruby Gem</a></li>
<li><a href='http://help.postageapp.com'>PostageApp Help Portal</a></li>
</ul>
</div>
</body>
</html>
3 changes: 3 additions & 0 deletions app/views/mailer/message.text.html.erb
@@ -0,0 +1,3 @@
<%= @html_content %>

HTML content
3 changes: 3 additions & 0 deletions app/views/mailer/message.text.plain.erb
@@ -0,0 +1,3 @@
<%= @text_content %>

Plain text content
32 changes: 32 additions & 0 deletions app/views/welcome/index.html.erb
@@ -0,0 +1,32 @@
<div class='api_key'>
<% if @api_key %>
API KEY: <span><%= @api_key %></span>
<% else %>
Please insert your project API KEY in <span>/config/initializers/postageapp.rb<span>
<% end %>
</div>

<% if @response %>
<div class='response'>
<pre><%= @response.to_yaml %></pre>
</div>
<% end%>
<% form_tag root_path do %>
<label> Subject
<%= text_field_tag :subject, @subject %>
</label>
<label>To ( email address )
<%= text_field_tag :to, @to %>
</label>
<label> Name ( {{name}} variable )
<%= text_field_tag :variable, @variable %>
</label>
<label> HTML Content
<%= text_area_tag :html, @html %>
</label>
<label> Plain Text Content
<%= text_area_tag :text, @text %>
</label>
<%= submit_tag 'Send Message' %>
<% end %>
2 changes: 1 addition & 1 deletion config/initializers/postageapp.rb
@@ -1,3 +1,3 @@
PostageApp.configure do |config|
config.api_key = 'ikm6a818RO4cPeS8EPRpDGQ9a63mPtDp'
config.api_key = 'PROJECT_API_KEY'
end
2 changes: 1 addition & 1 deletion config/routes.rb
Expand Up @@ -31,7 +31,7 @@
# end

# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
# map.root :controller => "welcome"
map.root :controller => "welcome"

# See how all your routes lay out with "rake routes"

Expand Down
Binary file added public/images/header.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/postageapp.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 46832da

Please sign in to comment.