Skip to content

Commit

Permalink
port to rails 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
coolo committed Nov 8, 2012
1 parent 937f3cc commit c190ff1
Show file tree
Hide file tree
Showing 80 changed files with 947 additions and 1,721 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ public/113
public/developer
tmp/appdata-factory.xml
.idea

public/assets
18 changes: 18 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
gem 'rails', '~> 3.2.1'
gem 'nokogiri'
gem 'gettext_i18n_rails'
gem 'gettext', '>=1.9.3', :require => false, :group => :development

gem 'mysql2'

gem 'delayed_job', '>3.0'
gem 'delayed_job_active_record'

gem 'xmlhash', '>= 1.2.2'

gem 'jquery-rails'
gem 'http_accept_language'

gem 'memcache-client'
gem 'sqlite3'
gem 'minitest'
119 changes: 119 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
GEM
specs:
actionmailer (3.2.8)
actionpack (= 3.2.8)
mail (~> 2.4.4)
actionpack (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.0)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.3)
activemodel (3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
activerecord (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
activesupport (3.2.8)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.0)
delayed_job (3.0.3)
activesupport (~> 3.0)
delayed_job_active_record (0.3.2)
activerecord (> 2.1.0)
delayed_job (~> 3.0.0)
erubis (2.7.0)
fast_gettext (0.6.9)
gettext (2.3.0)
locale
gettext_i18n_rails (0.7.1)
fast_gettext (>= 0.4.8)
hike (1.2.1)
http_accept_language (1.0.3)
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.1.1)
railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
json (1.7.5)
locale (2.0.8)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
memcache-client (1.8.5)
mime-types (1.19)
minitest (3.3.0)
multi_json (1.3.6)
mysql2 (0.3.11)
nokogiri (1.5.5)
pkg-config (1.1.4)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.8)
actionmailer (= 3.2.8)
actionpack (= 3.2.8)
activerecord (= 3.2.8)
activeresource (= 3.2.8)
activesupport (= 3.2.8)
bundler (~> 1.0)
railties (= 3.2.8)
railties (3.2.8)
actionpack (= 3.2.8)
activesupport (= 3.2.8)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.6)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
xmlhash (1.2.2)
pkg-config

PLATFORMS
ruby

DEPENDENCIES
delayed_job (> 3.0)
delayed_job_active_record
gettext (>= 1.9.3)
gettext_i18n_rails
http_accept_language
jquery-rails
memcache-client
minitest
mysql2
nokogiri
rails (~> 3.2.1)
sqlite3
xmlhash (>= 1.2.2)
10 changes: 4 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#!/usr/bin/env rake
# 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 File.expand_path('../config/application', __FILE__)

require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
SoftwareOO::Application.load_tasks

require 'tasks/rails'
require 'delayed/tasks'
require(File.join(File.dirname(__FILE__), 'config', 'boot'))

11 changes: 6 additions & 5 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

require 'api_connect'
require 'net/https'

class ApplicationController < ActionController::Base

#before_filter :set_gettext_locale
before_filter :set_language
before_filter :set_distributions
before_filter :set_baseproject

helper :all # include all helpers, all the time
require "rexml/document"

init_gettext('software')

class MissingParameterError < Exception; end

protected
Expand All @@ -32,8 +32,9 @@ def rescue_action_in_public(exception)
end

def set_language
logger.debug "params #{params.inspect}"
if params[:lang]
@lang = params[:lang][0]
@lang = params[:lang]
elsif cookies[:lang]
@lang = cookies[:lang]
end
Expand All @@ -46,7 +47,7 @@ def set_language
end
end
@lang.gsub!(/-/, '_')
GetText.locale = @lang
FastGettext.locale = @lang
end


Expand All @@ -69,7 +70,7 @@ def load_distributions
logger.debug "Loading distributions"
@distributions = Array.new
begin
response = ApiConnect::get("distributions")
response = ApiConnect::get("public/distributions")
doc = REXML::Document.new response.body
doc.elements.each("distributions/distribution") { |element|
dist = Hash[:name => element.elements['name'].text, :project => element.elements['project'].text,
Expand Down
6 changes: 1 addition & 5 deletions app/controllers/main_controller.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
require 'net/http'
require 'gettext_rails'

class MainController < ApplicationController

verify :only => :ymp, :params => [:project, :repository, :arch, :binary],
:redirect_to => :index

# these pages are completely static:
caches_page :release, :download_js
caches_page :release, :download_js unless Rails.env.development?

def ymp_with_arch_and_version
path = "/published/#{params[:project]}/#{params[:repository]}/#{params[:arch]}/#{params[:binary]}?view=ymp"
Expand Down
4 changes: 2 additions & 2 deletions app/models/seeker.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'md5'
require 'digest/md5'

class Seeker < ActiveXML::Base

Expand All @@ -8,7 +8,7 @@ def self.prepare_result(query, baseproject=nil, project=nil, exclude_filter=nil,
cache_key += "_#{exclude_filter}" if exclude_filter
cache_key += "_#{exclude_debug}" if exclude_debug
cache_key += "_#{project}" if project
cache_key = 'searchresult_' + MD5::md5( cache_key ).to_s
cache_key = 'searchresult_' + Digest::MD5.hexdigest( cache_key ).to_s
Rails.cache.fetch(cache_key, :expires_in => 120.minutes) do
SearchResult.search(query, baseproject, project, exclude_filter, exclude_debug)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<%= render :partial => 'search/find_form' unless @hide_search_box %>

<div id="search_result_container">
<%= @content_for_layout %>
<%= yield %>
</div>
</div>

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
<h4 style="width: 200px; "><%= _("Documentation") %></h4>
<ul style="padding: 0px; margin-top: 0px; margin-left: 2em; display: table; list-style: disc outside none; ">
<li><%= _("<a href=\"http://doc.opensuse.org/products/opensuse/openSUSE/opensuse-startup/\">openSUSE startup guide</a>") %></li>
<li><%= _("<a href='%s'>Release Notes</a>") % @releasenotes %></li>
<li><%=_('<a href="http://en.opensuse.org/openSUSE:License">License</a>')%></li>
<li><%= (_("<a href=\'%s\'>Release Notes</a>") % @releasenotes).html_safe %></li>
<li><%= _('<a href="http://en.opensuse.org/openSUSE:License">License</a>')%></li>
</ul>
</div>

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
run SoftwareOO::Application
98 changes: 98 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
require File.expand_path('../boot', __FILE__)

require 'rails/all'

if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end

module SoftwareOO
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.

# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)

# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]

# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer

# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'

# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de

# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"

# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]

# Use SQL instead of Active Record's schema dumper when creating the database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql

# Enforce whitelist mode for mass assignment.
# This will create an empty whitelist of attributes available for mass-assignment for all models
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
# parameters by using an attr_accessible or attr_protected declaration.
config.active_record.whitelist_attributes = true

# Enable the asset pipeline
config.assets.enabled = false

# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'

# Skip frameworks you're not going to use
#config.frameworks -= [ :action_web_service, :active_resource ]

# Add additional load paths for your own custom dirs
# config.load_paths += %W( #{Rails.root}/extras )

# Rails.root is not working directory when running under lighttpd, so it has
# to be added to load path
#config.load_paths << Rails.root unless config.load_paths.include? Rails.root

# Force all environments to use the same logger level
# (by default production uses :info, the others :debug)
# config.log_level = :debug

# Use the database for sessions instead of the file system
# (create the session table with 'rake create_sessions_table')
# config.action_controller.session_store = :active_record_store

config.cache_store = :mem_cache_store, 'localhost:11211', {namespace: 'software', compress: true}

# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector

# Make Active Record use UTC-base instead of local time
# config.active_record.default_timezone = :utc

config.action_controller.perform_caching = true

config.exceptions_app = self.routes

# See Rails::Configuration for more options
config.after_initialize do
# ExceptionNotifier.exception_recipients = CONFIG["exception_recipients"]
# ExceptionNotifier.sender_address = CONFIG["exception_sender"]
end unless Rails.env.test?

config.active_support.deprecation = :log

end
end
Loading

0 comments on commit c190ff1

Please sign in to comment.