Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Apr 1, 2013
0 parents commit 31e8304
Show file tree
Hide file tree
Showing 981 changed files with 393,236 additions and 0 deletions.
182 changes: 182 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
== Welcome to Rails

Rails is a web-application and persistence framework that includes everything
needed to create database-backed web-applications according to the
Model-View-Control pattern of separation. This pattern splits the view (also
called the presentation) into "dumb" templates that are primarily responsible
for inserting pre-built data in between HTML tags. The model contains the
"smart" domain objects (such as Account, Product, Person, Post) that holds all
the business logic and knows how to persist themselves to a database. The
controller handles the incoming requests (such as Save New Account, Update
Product, Show Post) by manipulating the model and directing data to the view.

In Rails, the model is handled by what's called an object-relational mapping
layer entitled Active Record. This layer allows you to present the data from
database rows as objects and embellish these data objects with business logic
methods. You can read more about Active Record in
link:files/vendor/rails/activerecord/README.html.

The controller and view are handled by the Action Pack, which handles both
layers by its two parts: Action View and Action Controller. These two layers
are bundled in a single package due to their heavy interdependence. This is
unlike the relationship between the Active Record and Action Pack that is much
more separate. Each of these packages can be used independently outside of
Rails. You can read more about Action Pack in
link:files/vendor/rails/actionpack/README.html.


== Getting started

1. At the command prompt, start a new rails application using the rails command
and your application name. Ex: rails myapp
(If you've downloaded rails in a complete tgz or zip, this step is already done)
2. Change directory into myapp and start the web server: <tt>script/server</tt> (run with --help for options)
3. Go to http://localhost:3000/ and get "Welcome aboard: You’re riding the Rails!"
4. Follow the guidelines to start developing your application


== Web Servers

By default, Rails will try to use Mongrel and lighttpd if they are installed, otherwise
Rails will use the WEBrick, the webserver that ships with Ruby. When you run script/server,
Rails will check if Mongrel exists, then lighttpd and finally fall back to WEBrick. This ensures
that you can always get up and running quickly.

Mongrel is a Ruby-based webserver with a C-component (which requires compilation) that is
suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>.
More info at: http://mongrel.rubyforge.org

If Mongrel is not installed, Rails will look for lighttpd. It's considerably faster than
Mongrel and WEBrick and also suited for production use, but requires additional
installation and currently only works well on OS X/Unix (Windows users are encouraged
to start with Mongrel). We recommend version 1.4.11 and higher. You can download it from
http://www.lighttpd.net.

And finally, if neither Mongrel or lighttpd are installed, Rails will use the built-in Ruby
web server, WEBrick. WEBrick is a small Ruby web server suitable for development, but not
for production.

But of course its also possible to run Rails on any platform that supports FCGI.
Apache, LiteSpeed, IIS are just a few. For more information on FCGI,
please visit: http://wiki.rubyonrails.com/rails/pages/FastCGI


== Debugging Rails

Have "tail -f" commands running on the server.log and development.log. Rails will
automatically display debugging and runtime information to these files. Debugging
info will also be shown in the browser on requests from 127.0.0.1.


== Breakpoints

Breakpoint support is available through the script/breakpointer client. This
means that you can break out of execution at any point in the code, investigate
and change the model, AND then resume execution! Example:

class WeblogController < ActionController::Base
def index
@posts = Post.find(:all)
breakpoint "Breaking out from the list"
end
end

So the controller will accept the action, run the first line, then present you
with a IRB prompt in the breakpointer window. Here you can do things like:

Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint'

>> @posts.inspect
=> "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
#<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
>> @posts.first.title = "hello from a breakpoint"
=> "hello from a breakpoint"

...and even better is that you can examine how your runtime objects actually work:

>> f = @posts.first
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
>> f.
Display all 152 possibilities? (y or n)

Finally, when you're ready to resume execution, you press CTRL-D


== Console

You can interact with the domain model by starting the console through <tt>script/console</tt>.
Here you'll have all parts of the application configured, just like it is when the
application is running. You can inspect domain models, change values, and save to the
database. Starting the script without arguments will launch it in the development environment.
Passing an argument will specify a different environment, like <tt>script/console production</tt>.

To reload your controllers and models after launching the console run <tt>reload!</tt>

To reload your controllers and models after launching the console run <tt>reload!</tt>



== Description of contents

app
Holds all the code that's specific to this particular application.

app/controllers
Holds controllers that should be named like weblogs_controller.rb for
automated URL mapping. All controllers should descend from ApplicationController
which itself descends from ActionController::Base.

app/models
Holds models that should be named like post.rb.
Most models will descend from ActiveRecord::Base.

app/views
Holds the template files for the view that should be named like
weblogs/index.rhtml for the WeblogsController#index action. All views use eRuby
syntax.

app/views/layouts
Holds the template files for layouts to be used with views. This models the common
header/footer method of wrapping views. In your views, define a layout using the
<tt>layout :default</tt> and create a file named default.rhtml. Inside default.rhtml,
call <% yield %> to render the view using this layout.

app/helpers
Holds view helpers that should be named like weblogs_helper.rb. These are generated
for you automatically when using script/generate for controllers. Helpers can be used to
wrap functionality for your views into methods.

config
Configuration files for the Rails environment, the routing map, the database, and other dependencies.

components
Self-contained mini-applications that can bundle together controllers, models, and views.

db
Contains the database schema in schema.rb. db/migrate contains all
the sequence of Migrations for your schema.

doc
This directory is where your application documentation will be stored when generated
using <tt>rake doc:app</tt>

lib
Application specific libraries. Basically, any kind of custom code that doesn't
belong under controllers, models, or helpers. This directory is in the load path.

public
The directory available for the web server. Contains subdirectories for images, stylesheets,
and javascripts. Also contains the dispatchers and the default HTML files. This should be
set as the DOCUMENT_ROOT of your web server.

script
Helper scripts for automation and generation.

test
Unit and functional tests along with fixtures. When using the script/generate scripts, template
test files will be generated for you and placed in this directory.

vendor
External libraries that the application depends on. Also includes the plugins subdirectory.
This directory is in the load path.
10 changes: 10 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require(File.join(File.dirname(__FILE__), 'config', 'boot'))

require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

require 'tasks/rails'
12 changes: 12 additions & 0 deletions app/controllers/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
# Pick a unique cookie name to distinguish our session data from others'
session :session_key => '_cheepr_session_id'

def initialize
@ar = AmazonRegions.find(1)
end

end
78 changes: 78 additions & 0 deletions app/controllers/feeds_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
class FeedsController < ApplicationController
def index
list
render :action => 'list'
end

def search
#render :partial => 'search'
end

def preview
render :partial => 'preview'
end

def play2
render :partial => 'play2'
end

# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
verify :method => :post, :only => [ :destroy, :create, :update ],
:redirect_to => { :action => :list }

def list
@feed_pages, @feeds = paginate :feeds, :per_page => 10
end

def show
action_name = "hello!"
@feed = Feed.find(params[:id])

#render() and return false
end

def rss
render (:file => 'feeds/rss.rxml', :use_full_path => true)
end

def new
@feed = Feed.new
end

def go
redirect_to 'http://www.amazon.co.uk/gp/offer-listing/' + params[:id]
end

def create
@feed = Feed.new(params[:feed])
if @feed.save
flash[:notice] = 'Feed was successfully created.'
redirect_to :action => 'show', :id => @feed.id
else
render :action => 'new'
end
end

def edit
@feed = Feed.find(params[:id])
end

def ecs

end

def update
@feed = Feed.find(params[:id])
if @feed.update_attributes(params[:feed])
flash[:notice] = 'Feed was successfully updated.'
redirect_to :action => 'show', :id => @feed
else
render :action => 'edit'
end
end

def destroy
Feed.find(params[:id]).destroy
redirect_to :action => 'list'
end
end
3 changes: 3 additions & 0 deletions app/controllers/welcome_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class WelcomeController < ApplicationController
#layout => 'feeds'
end
3 changes: 3 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end
2 changes: 2 additions & 0 deletions app/helpers/feeds_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module FeedsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/welcome_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module WelcomeHelper
end
2 changes: 2 additions & 0 deletions app/models/amazon_regions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class AmazonRegions < ActiveRecord::Base
end
52 changes: 52 additions & 0 deletions app/models/amazon_stuff.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
require 'amazon/search'
#require 'amazon/search/exchange'
#require 'amazon/search/exchange/marketplace'
#require 'amazon/search/exchange/thirdparty'
#include Amazon::Search # don't want to have to fully qualify identifiers
#include Amazon::Search::Blended
#include Amazon::Wishlist

class AmazonStuff

associates_id = "amazocoukrssf-21"
dev_token = "05403WA231975K3716G2"
@@request4 = Amazon::Search::Exchange::Request.new(dev_token, associates_id) # second argument optional
@@request2 = Amazon::Search::Exchange::Marketplace::Request.new(dev_token, associates_id) # second argument optional
@@request5 = Amazon::Search::Exchange::ThirdParty::Request.new(dev_token, associates_id)
@@request = Amazon::Search::Request.new(dev_token, associates_id) # second argument optional
@@request3 = Amazon::Search::Seller::Request.new(dev_token, associates_id) # second argument optional

def self.keyword_search(asin)
@response = @@request2.keyword_search('A3ADN03F2ABAVW', 'megadeth')
end

def self.listing_search
@response = @@request2.listing_search('A3ADN03F2ABAVW', 'listing_id', Amazon::Search::HEAVY)
end

def self.seller_search
@response = @@request5.seller_search('A3ADN03F2ABAVW')
end

def self.exchange_search
@response = @@request4.search('Y05Y3280202Y0313808')
end

def self.testfunc
"boo!"
end

def self.wishlist_search
@response = @@request.wishlist_search('YLR0UQZFT2K7', Amazon::Search::LITE)
end

def self.asin_search(asin)
@response = @@request.asin_search(asin, Amazon::Search::HEAVY)
end

def self.search(search_string)
unless search_string.blank?
@response = @@request.keyword_search(search_string, 'Beauty', Amazon::Search::LITE)
end
end
end
18 changes: 18 additions & 0 deletions app/models/cache_seller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class CacheSeller < ActiveRecord::Base
def getSeller(sellerId)

a_cache_seller = CacheSeller.find(:all, :conditions => ["seller_id = ?", seller_id])

# if missing or old then re-request


seller = sellerLookup(sellerId)

a_cache_seller = CacheSeller.new
a_cache_seller.nickname = Amazon::Element.get_unescaped(seller.doc, 'nickname')
a_cache_seller.glancepage = Amazon::Element.get_unescaped(seller.doc, 'glancepage')
a_cache_seller.save


end
end
Loading

0 comments on commit 31e8304

Please sign in to comment.