├── .gitignore ├── rails └── init.rb ├── autotest └── discover.rb ├── lib ├── generators │ └── mugen │ │ ├── templates │ │ ├── public │ │ │ ├── images │ │ │ │ └── mygengo │ │ │ │ │ └── blank │ │ │ └── stylesheets │ │ │ │ └── mygengo │ │ │ │ ├── override.css │ │ │ │ ├── scaffold.css │ │ │ │ ├── mugen.css │ │ │ │ ├── base.css │ │ │ │ └── style.css │ │ ├── config │ │ │ ├── initializers │ │ │ │ └── mugen.rb │ │ │ ├── routes3.rb │ │ │ └── routes2.rb │ │ └── app │ │ │ ├── views │ │ │ ├── mygengo │ │ │ │ ├── account │ │ │ │ │ ├── _balance.haml │ │ │ │ │ ├── index.haml │ │ │ │ │ └── _stats.haml │ │ │ │ ├── jobs │ │ │ │ │ ├── _revision.haml │ │ │ │ │ ├── revision.haml │ │ │ │ │ ├── _feedback.haml │ │ │ │ │ ├── index.haml │ │ │ │ │ ├── revise_form.haml │ │ │ │ │ ├── _comments.haml │ │ │ │ │ ├── _job.haml │ │ │ │ │ ├── reject_form.haml │ │ │ │ │ ├── show.haml │ │ │ │ │ ├── new.haml │ │ │ │ │ └── review_form.haml │ │ │ │ └── comments │ │ │ │ │ ├── _comment.haml │ │ │ │ │ └── _form.haml │ │ │ └── layouts │ │ │ │ └── mygengo.html.erb │ │ │ ├── helpers │ │ │ └── mugen_helper.rb │ │ │ └── controllers │ │ │ └── mygengo │ │ │ ├── comments_controller.rb │ │ │ ├── account_controller.rb │ │ │ ├── mygengo_controller.rb │ │ │ └── jobs_controller.rb │ │ ├── README │ │ ├── USAGE │ │ └── mugen_generator.rb ├── mugen │ ├── version.rb │ ├── account.rb │ ├── service.rb │ ├── httparty_extensions.rb │ ├── core_extensions.rb │ ├── jobs.rb │ ├── client.rb │ └── job.rb ├── tasks │ └── mugen.rake └── mugen.rb ├── CHANGELOG.md ├── Gemfile ├── spec ├── spec_helper.rb ├── service_spec.rb ├── account_spec.rb ├── mugen_spec.rb ├── jobs_spec.rb └── job_spec.rb ├── .travis.yml ├── generators ├── templates │ ├── config │ │ ├── routes.rb │ │ └── initializers │ │ │ └── mugen.rb │ ├── app │ │ ├── helpers │ │ │ └── mugen_helper.rb │ │ ├── views │ │ │ ├── mygengo │ │ │ │ ├── jobs │ │ │ │ │ ├── new.haml │ │ │ │ │ ├── _job.haml │ │ │ │ │ ├── index.haml │ │ │ │ │ ├── show.haml │ │ │ │ │ ├── revision.haml │ │ │ │ │ ├── _comments.haml │ │ │ │ │ ├── _feedback.haml │ │ │ │ │ ├── _revision.haml │ │ │ │ │ ├── reject_form.haml │ │ │ │ │ ├── review_form.haml │ │ │ │ │ └── revise_form.haml │ │ │ │ ├── account │ │ │ │ │ ├── index.haml │ │ │ │ │ ├── _balance.haml │ │ │ │ │ └── _stats.haml │ │ │ │ └── comments │ │ │ │ │ ├── _form.haml │ │ │ │ │ └── _comment.haml │ │ │ └── layouts │ │ │ │ └── mygengo.html.erb │ │ └── controllers │ │ │ └── mygengo │ │ │ ├── jobs_controller.rb │ │ │ ├── account_controller.rb │ │ │ └── comments_controller.rb │ └── public │ │ └── stylesheets │ │ └── mygengo │ │ ├── override.css │ │ ├── scaffold.css │ │ ├── mugen.css │ │ ├── base.css │ │ └── style.css ├── README ├── USAGE └── mugen_generator.rb ├── Rakefile ├── LICENSE ├── mugen.gemspec └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | pkg 2 | *.lock 3 | -------------------------------------------------------------------------------- /rails/init.rb: -------------------------------------------------------------------------------- 1 | require "mugen" 2 | -------------------------------------------------------------------------------- /autotest/discover.rb: -------------------------------------------------------------------------------- 1 | Autotest.add_discovery { "rspec2" } -------------------------------------------------------------------------------- /lib/generators/mugen/templates/public/images/mygengo/blank: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.0.1 (January 2, 2011) 2 | 3 | Features: 4 | -------------------------------------------------------------------------------- /lib/mugen/version.rb: -------------------------------------------------------------------------------- 1 | module Mugen 2 | VERSION = "0.2.1" 3 | end -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "http://rubygems.org" 2 | 3 | gemspec 4 | 5 | gem 'rake' 6 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require "bundler" 2 | Bundler.setup 3 | 4 | require "mugen" -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - "1.9.2" 4 | script: 5 | - bundle exec rspec spec/ -------------------------------------------------------------------------------- /generators/templates/config/routes.rb: -------------------------------------------------------------------------------- 1 | ../../../lib/generators/mugen/templates/config/routes2.rb -------------------------------------------------------------------------------- /lib/tasks/mugen.rake: -------------------------------------------------------------------------------- 1 | namespace :mugen do 2 | task :hello 3 | puts 'Hello' 4 | end 5 | end -------------------------------------------------------------------------------- /lib/generators/mugen/templates/config/initializers/mugen.rb: -------------------------------------------------------------------------------- 1 | Mugen.api_key = '' 2 | Mugen.private_key = '' -------------------------------------------------------------------------------- /generators/templates/app/helpers/mugen_helper.rb: -------------------------------------------------------------------------------- 1 | ../../../../lib/generators/mugen/templates/app/helpers/mugen_helper.rb -------------------------------------------------------------------------------- /generators/templates/public/stylesheets/mygengo/override.css: -------------------------------------------------------------------------------- 1 | /* Override here any style defined by web-app-theme */ -------------------------------------------------------------------------------- /generators/templates/config/initializers/mugen.rb: -------------------------------------------------------------------------------- 1 | ../../../../lib/generators/mugen/templates/config/initializers/mugen.rb -------------------------------------------------------------------------------- /lib/generators/mugen/README: -------------------------------------------------------------------------------- 1 | This directory is for the Rails 3 generator. 2 | 3 | The Rails 2.x generator is in /generators. 4 | -------------------------------------------------------------------------------- /lib/generators/mugen/templates/public/stylesheets/mygengo/override.css: -------------------------------------------------------------------------------- 1 | /* Override here any style defined by web-app-theme */ -------------------------------------------------------------------------------- /generators/templates/app/views/mygengo/jobs/new.haml: -------------------------------------------------------------------------------- 1 | ../../../../../../lib/generators/mugen/templates/app/views/mygengo/jobs/new.haml -------------------------------------------------------------------------------- /generators/README: -------------------------------------------------------------------------------- 1 | This directory is for the Rails 2.x generator. 2 | 3 | The (Thor-based) Rails 3 generator is in lib/generators. 4 | -------------------------------------------------------------------------------- /generators/templates/app/views/layouts/mygengo.html.erb: -------------------------------------------------------------------------------- 1 | ../../../../../lib/generators/mugen/templates/app/views/layouts/mygengo.html.erb -------------------------------------------------------------------------------- /generators/templates/app/views/mygengo/jobs/_job.haml: -------------------------------------------------------------------------------- 1 | ../../../../../../lib/generators/mugen/templates/app/views/mygengo/jobs/_job.haml -------------------------------------------------------------------------------- /generators/templates/app/views/mygengo/jobs/index.haml: -------------------------------------------------------------------------------- 1 | ../../../../../../lib/generators/mugen/templates/app/views/mygengo/jobs/index.haml -------------------------------------------------------------------------------- /generators/templates/app/views/mygengo/jobs/show.haml: -------------------------------------------------------------------------------- 1 | ../../../../../../lib/generators/mugen/templates/app/views/mygengo/jobs/show.haml -------------------------------------------------------------------------------- /generators/templates/app/views/mygengo/account/index.haml: -------------------------------------------------------------------------------- 1 | ../../../../../../lib/generators/mugen/templates/app/views/mygengo/account/index.haml -------------------------------------------------------------------------------- /generators/templates/app/views/mygengo/jobs/revision.haml: -------------------------------------------------------------------------------- 1 | ../../../../../../lib/generators/mugen/templates/app/views/mygengo/jobs/revision.haml -------------------------------------------------------------------------------- /generators/templates/app/views/mygengo/account/_balance.haml: -------------------------------------------------------------------------------- 1 | ../../../../../../lib/generators/mugen/templates/app/views/mygengo/account/_balance.haml -------------------------------------------------------------------------------- /generators/templates/app/views/mygengo/account/_stats.haml: -------------------------------------------------------------------------------- 1 | ../../../../../../lib/generators/mugen/templates/app/views/mygengo/account/_stats.haml -------------------------------------------------------------------------------- /generators/templates/app/views/mygengo/comments/_form.haml: -------------------------------------------------------------------------------- 1 | ../../../../../../lib/generators/mugen/templates/app/views/mygengo/comments/_form.haml -------------------------------------------------------------------------------- /generators/templates/app/views/mygengo/jobs/_comments.haml: -------------------------------------------------------------------------------- 1 | ../../../../../../lib/generators/mugen/templates/app/views/mygengo/jobs/_comments.haml -------------------------------------------------------------------------------- /generators/templates/app/views/mygengo/jobs/_feedback.haml: -------------------------------------------------------------------------------- 1 | ../../../../../../lib/generators/mugen/templates/app/views/mygengo/jobs/_feedback.haml -------------------------------------------------------------------------------- /generators/templates/app/views/mygengo/jobs/_revision.haml: -------------------------------------------------------------------------------- 1 | ../../../../../../lib/generators/mugen/templates/app/views/mygengo/jobs/_revision.haml -------------------------------------------------------------------------------- /generators/templates/app/views/mygengo/jobs/reject_form.haml: -------------------------------------------------------------------------------- 1 | ../../../../../../lib/generators/mugen/templates/app/views/mygengo/jobs/reject_form.haml -------------------------------------------------------------------------------- /generators/templates/app/views/mygengo/jobs/review_form.haml: -------------------------------------------------------------------------------- 1 | ../../../../../../lib/generators/mugen/templates/app/views/mygengo/jobs/review_form.haml -------------------------------------------------------------------------------- /generators/templates/app/views/mygengo/jobs/revise_form.haml: -------------------------------------------------------------------------------- 1 | ../../../../../../lib/generators/mugen/templates/app/views/mygengo/jobs/revise_form.haml -------------------------------------------------------------------------------- /generators/templates/app/controllers/mygengo/jobs_controller.rb: -------------------------------------------------------------------------------- 1 | ../../../../../lib/generators/mugen/templates/app/controllers/mygengo/jobs_controller.rb -------------------------------------------------------------------------------- /generators/templates/app/views/mygengo/comments/_comment.haml: -------------------------------------------------------------------------------- 1 | ../../../../../../lib/generators/mugen/templates/app/views/mygengo/comments/_comment.haml -------------------------------------------------------------------------------- /generators/templates/app/controllers/mygengo/account_controller.rb: -------------------------------------------------------------------------------- 1 | ../../../../../lib/generators/mugen/templates/app/controllers/mygengo/account_controller.rb -------------------------------------------------------------------------------- /generators/templates/app/controllers/mygengo/comments_controller.rb: -------------------------------------------------------------------------------- 1 | ../../../../../lib/generators/mugen/templates/app/controllers/mygengo/comments_controller.rb -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/views/mygengo/account/_balance.haml: -------------------------------------------------------------------------------- 1 | .mygengo-box 2 | .account-balance 3 | %h4 Credit balance 4 | = @account["credits"] 5 | credits -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/views/mygengo/account/index.haml: -------------------------------------------------------------------------------- 1 | %h1 Account info 2 | = render :partial => 'mygengo/account/balance' 3 | = render :partial => 'mygengo/account/stats' 4 | -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/views/mygengo/jobs/_revision.haml: -------------------------------------------------------------------------------- 1 | %li 2 | = link_to revision['rev_id'], revision_mygengo_job_path(:job_id => job['job_id'], :id => revision['rev_id']) 3 | -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/views/mygengo/comments/_comment.haml: -------------------------------------------------------------------------------- 1 | %tr 2 | %td(colspan=2) 3 | = comment['body'] 4 | %br 5 | = comment['author'] 6 | | 7 | = d (comment['ctime']) -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/views/mygengo/jobs/revision.haml: -------------------------------------------------------------------------------- 1 | %h2 Job: #{@job['job_id']} 2 | 3 | %p 4 | Source: 5 | %br 6 | = @revision['body_tgt'] 7 | 8 | = link_to 'Back', mygengo_job_path(@job['job_id']) -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/views/mygengo/jobs/_feedback.haml: -------------------------------------------------------------------------------- 1 | .mygengo-box 2 | %h4 Feedback 3 | %p 4 | Rating: 5 | = feedback['rating'] 6 | %p 7 | For translator: 8 | = feedback['for_translator'] 9 | -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/views/mygengo/jobs/index.haml: -------------------------------------------------------------------------------- 1 | %h3 Jobs listing 2 | 3 | %table.general 4 | - for job in @jobs 5 | = render :partial => 'mygengo/jobs/job', :locals => {:job => job} 6 | 7 | %br 8 | = link_to 'Create a job', new_mygengo_job_path 9 | -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/views/mygengo/account/_stats.haml: -------------------------------------------------------------------------------- 1 | .mygengo-box 2 | .account-stats 3 | %h4 Account Stats 4 | %p 5 | Credits spent: 6 | = @account["credits_spent"] 7 | %p 8 | User Since: 9 | = d @account["user_since"] -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/views/mygengo/jobs/revise_form.haml: -------------------------------------------------------------------------------- 1 | %h3 Revise 2 | = form_for :job, :url => {:action => 'revise', :id => @job['job_id']} do |f| 3 | .field 4 | Comment 5 | %br 6 | = text_area_tag 'job[comment]', '', :size => '40x7' 7 | = f.submit 'Revise' -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/views/mygengo/jobs/_comments.haml: -------------------------------------------------------------------------------- 1 | - if comments.size > 0 2 | %h4 Comments 3 | %table.mygento-comments 4 | - for comment in comments 5 | = render :partial => 'mygengo/comments/comment', :locals => {:comment => comment} 6 | %br 7 | - else 8 | No comments -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/helpers/mugen_helper.rb: -------------------------------------------------------------------------------- 1 | module MugenHelper 2 | def d(timestamp) 3 | if timestamp 4 | Time.at(timestamp).to_s(:short) 5 | end 6 | end 7 | 8 | def eta(timestamp) 9 | time_ago_in_words(Time.at(timestamp)) unless timestamp.empty? 10 | end 11 | end -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/controllers/mygengo/comments_controller.rb: -------------------------------------------------------------------------------- 1 | class Mygengo::CommentsController < Mygengo::MygengoController 2 | def create 3 | flag = Mugen::Job.create_comment(params[:id], params[:comment]) 4 | redirect_to mygengo_job_path(params[:id]) 5 | end 6 | end -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/controllers/mygengo/account_controller.rb: -------------------------------------------------------------------------------- 1 | class Mygengo::AccountController < Mygengo::MygengoController 2 | 3 | def index 4 | @account = Mugen::Account.balance || {} 5 | @stats = Mugen::Account.stats 6 | 7 | @account.merge! @stats if @stats 8 | end 9 | 10 | end -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/views/mygengo/comments/_form.haml: -------------------------------------------------------------------------------- 1 | %h3 Leave a comment 2 | = form_for :comment, :url => {:controller => 'mygengo/comments', :action => 'create', :id => @job['job_id']} do |f| 3 | .field 4 | Text 5 | %br 6 | = f.text_area :body, :size => '40x7' 7 | .field 8 | Requesting personal contact details from translators is prohibited 9 | = f.submit "Submit Comment" 10 | %br -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/controllers/mygengo/mygengo_controller.rb: -------------------------------------------------------------------------------- 1 | class Mygengo::MygengoController < ApplicationController 2 | before_render :parse_errrors 3 | layout 'mygengo' 4 | 5 | protected 6 | 7 | def parse_errrors 8 | unless Mugen.errors.empty? 9 | if flash[:error] 10 | flash[:error] << Mugen.errors.join(' | ') 11 | else 12 | flash[:error] = Mugen.errors.join(' | ') 13 | end 14 | Mugen.errors.clear 15 | end 16 | end 17 | 18 | end -------------------------------------------------------------------------------- /lib/generators/mugen/templates/config/routes3.rb: -------------------------------------------------------------------------------- 1 | namespace :mygengo do 2 | resources :jobs do 3 | member do 4 | get :review_form 5 | get :reject_form 6 | get :revise_form 7 | get :purchase 8 | post :reject 9 | post :revise 10 | post :approve 11 | post :callback 12 | end 13 | end 14 | resources :comments, :only => [:create] 15 | resources :account, :only => [:index] 16 | end 17 | match '/mygengo/jobs/:job_id/revision/:id' => 'mygengo/jobs#revision', :as => :revision_mygengo_job -------------------------------------------------------------------------------- /lib/generators/mugen/templates/config/routes2.rb: -------------------------------------------------------------------------------- 1 | map.namespace(:mygengo) do |admin| 2 | admin.resources :jobs, :member => { 3 | :review_form => :get, 4 | :reject_form => :get, 5 | :revise_form => :get, 6 | :purchase => :get, 7 | :reject => :post, 8 | :revise => :post, 9 | :approve => :post, 10 | :callback => :post, 11 | } 12 | admin.resources :comments, :only => [:create] 13 | admin.resources :account, :only => [:index] 14 | end 15 | 16 | map.revision_mygengo_job '/mygengo/jobs/:job_id/revision/:id', :controller => 'mygengo/jobs', :action => 'revision' 17 | -------------------------------------------------------------------------------- /lib/mugen/account.rb: -------------------------------------------------------------------------------- 1 | module Mugen 2 | class Account < Client 3 | class << self 4 | 5 | # 6 | # /account/stats (GET) 7 | # Retrieves account stats, such as orders made. 8 | # 9 | def stats(options={}) 10 | res = self.get "/account/stats", :query => options 11 | check_for_errors(res) 12 | res['response'] 13 | end 14 | 15 | # 16 | # /account/balance (GET) 17 | # Retrieves account balance in credits 18 | # 19 | def balance(options={}) 20 | res = self.get "/account/balance", :query => options 21 | check_for_errors(res) 22 | res['response'] 23 | end 24 | 25 | end 26 | end 27 | end -------------------------------------------------------------------------------- /spec/service_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Mugen::Service do 4 | before(:each) do 5 | Mugen.api_key = '6NO~NtyavKh@x-Uz@)0LG_PQ1KJI[(kd_2{oqv}H{ubO5Yu3is~IF^udRwM6QC6n' 6 | Mugen.private_key = 'w0F((zYj3=09(AD|2B7)jNT@5F[wajwk[6u^stF59wCfuCtwMEMB^c7y=5V~WM^K' 7 | @service = Mugen::Service 8 | end 9 | 10 | it "should retrieve language_pairs" do 11 | stats = @service.language_pairs 12 | stats.should be_a(Array) 13 | stats.should_not be_empty 14 | end 15 | 16 | it "should retrieve languages" do 17 | balance = @service.languages 18 | balance.should be_a(Array) 19 | balance.should_not be_empty 20 | end 21 | end -------------------------------------------------------------------------------- /spec/account_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Mugen::Account do 4 | before(:each) do 5 | Mugen.api_key = '6NO~NtyavKh@x-Uz@)0LG_PQ1KJI[(kd_2{oqv}H{ubO5Yu3is~IF^udRwM6QC6n' 6 | Mugen.private_key = 'w0F((zYj3=09(AD|2B7)jNT@5F[wajwk[6u^stF59wCfuCtwMEMB^c7y=5V~WM^K' 7 | @account = Mugen::Account 8 | end 9 | 10 | it "should retrieve stats" do 11 | stats = @account.stats 12 | stats.should be_a(Hash) 13 | stats.should have_key('credits_spent') 14 | stats.should have_key('user_since') 15 | end 16 | 17 | it "should retrieve balance" do 18 | balance = @account.balance 19 | balance.should be_a(Hash) 20 | balance.should have_key('credits') 21 | end 22 | end -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | begin 2 | require "bundler" 3 | Bundler.setup 4 | rescue LoadError 5 | $stderr.puts "You need to have Bundler installed to be able build this gem." 6 | end 7 | 8 | gemspec = eval(File.read(Dir["*.gemspec"].first)) 9 | 10 | 11 | desc "Validate the gemspec" 12 | task :gemspec do 13 | gemspec.validate 14 | end 15 | 16 | desc "Build gem locally" 17 | task :build => :gemspec do 18 | system "gem build #{gemspec.name}.gemspec" 19 | FileUtils.mkdir_p "pkg" 20 | FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", "pkg" 21 | end 22 | 23 | desc "Install gem locally" 24 | task :install => :build do 25 | system "gem install pkg/#{gemspec.name}-#{gemspec.version}" 26 | end 27 | 28 | desc "Clean automatically generated files" 29 | task :clean do 30 | FileUtils.rm_rf "pkg" 31 | end -------------------------------------------------------------------------------- /lib/mugen/service.rb: -------------------------------------------------------------------------------- 1 | module Mugen 2 | class Service < Client 3 | class << self 4 | 5 | # 6 | # translate/service/language_pairs (GET) 7 | # 8 | # Returns supported translation language pairs, tiers, and credit 9 | # prices. 10 | # 11 | def language_pairs(options={}) 12 | res = self.get "/translate/service/language_pairs", :query => options 13 | check_for_errors(res) 14 | res['response'] 15 | end 16 | 17 | # 18 | # translate/service/languages (GET) 19 | # 20 | # Returns a list of supported languages and their language codes. 21 | # 22 | def languages(options={}) 23 | res = self.get "/translate/service/languages", :query => options 24 | check_for_errors(res) 25 | res['response'] 26 | end 27 | 28 | end 29 | end 30 | end -------------------------------------------------------------------------------- /lib/mugen/httparty_extensions.rb: -------------------------------------------------------------------------------- 1 | module HTTParty 2 | module ClassMethods 3 | alias :original_get :get 4 | alias :original_post :post 5 | alias :original_put :put 6 | 7 | # Inject pre GET hook 8 | def get(path, options={}) 9 | path, options = before_get(path, options) if respond_to?(:before_get) 10 | original_get(path, options) 11 | end 12 | 13 | # Inject pre POST hook 14 | def post(path, options={}) 15 | path, options = before_post(path, options) if respond_to?(:before_post) 16 | original_post(path, options) 17 | end 18 | 19 | # Inject pre PUT hook 20 | def put(path, options={}) 21 | path, options = before_put(path, options) if respond_to?(:before_put) 22 | original_put(path, options) 23 | end 24 | 25 | end 26 | end -------------------------------------------------------------------------------- /lib/mugen/core_extensions.rb: -------------------------------------------------------------------------------- 1 | class Hash 2 | 3 | def sorted_hash 4 | self.keys.sort 5 | end 6 | 7 | # This hack to enables CGI::escape instead of URI.encode in to_params 8 | def normalize_param(key, value) 9 | param = '' 10 | stack = [] 11 | 12 | if value.is_a?(Array) 13 | param << value.map { |element| normalize_param("#{key}[]", element) }.join 14 | elsif value.is_a?(Hash) 15 | stack << [key,value] 16 | else 17 | param << "#{key}=#{CGI::escape(value.to_s)}&" 18 | end 19 | 20 | stack.each do |parent, hash| 21 | hash.each do |key, value| 22 | if value.is_a?(Hash) 23 | stack << ["#{parent}[#{key}]", value] 24 | else 25 | param << normalize_param("#{parent}[#{key}]", value) 26 | end 27 | end 28 | end 29 | 30 | param 31 | end 32 | end -------------------------------------------------------------------------------- /spec/mugen_spec.rb: -------------------------------------------------------------------------------- 1 | require "spec_helper" 2 | 3 | describe Mugen do 4 | it "should raise error if API URL is not specified" do 5 | Mugen.api_url.should == 'http://api.sandbox.mygengo.com/v1/' 6 | end 7 | 8 | it "should set API URL" do 9 | Mugen.api_url = "http://foobar.com" 10 | Mugen.api_url.should == "http://foobar.com" 11 | end 12 | 13 | it "should set API username" do 14 | Mugen.api_key = "12345" 15 | Mugen.api_key.should == "12345" 16 | end 17 | 18 | it "should raise error if API username is not specified" do 19 | Mugen.api_key = nil 20 | lambda { Mugen.api_key }.should raise_error 21 | end 22 | 23 | it "should set API password" do 24 | Mugen.private_key = "12345" 25 | Mugen.private_key.should == "12345" 26 | end 27 | 28 | it "should raise error if API password is not specified" do 29 | Mugen.private_key = nil 30 | lambda { Mugen.private_key }.should raise_error 31 | end 32 | 33 | end -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/views/mygengo/jobs/_job.haml: -------------------------------------------------------------------------------- 1 | %tr 2 | %td 3 | Job # 4 | = link_to job["job_id"], mygengo_job_path(job["job_id"]) 5 | %br 6 | = job['slug'] 7 | %td 8 | = job['status'] 9 | %br 10 | = job['tier'] 11 | %td 12 | = job['comments'].size 13 | comments 14 | %br 15 | = job['lc_src'] 16 | » 17 | =job['lc_tgt'] 18 | %td 19 | = job['credits'] 20 | credits 21 | %br 22 | = job['unit_count'] 23 | words 24 | %td 25 | = d job['ctime'] 26 | %br 27 | - unless job['eta'].empty? 28 | = eta(job['eta']) 29 | %td 30 | Actions 31 | %br 32 | = link_to 'Cancel', mygengo_job_path(job['job_id']), :method => :delete, :confirm => 'Are you sure?' 33 | - if job['status'] == 'reviewable' 34 | = link_to 'Review', review_form_mygengo_job_path(job["job_id"]) 35 | = link_to 'View', mygengo_job_path(job["job_id"]) 36 | 37 | -------------------------------------------------------------------------------- /lib/mugen/jobs.rb: -------------------------------------------------------------------------------- 1 | module Mugen 2 | class Jobs < Client 3 | class << self 4 | # 5 | # translate/jobs (GET) 6 | # 7 | # Retrieves a list of resources for the most recent jobs filtered 8 | # by the given parameters. 9 | # 10 | def all(options={}) 11 | res = self.get "/translate/jobs", :query => options 12 | check_for_errors(res) 13 | res['response'] 14 | end 15 | 16 | 17 | # 18 | # translate/jobs/{id} (GET) 19 | # 20 | # Retrieves the group of jobs that were previously submitted 21 | # together. 22 | # 23 | def by_group(id, options={}) 24 | res = self.get "/translate/jobs/#{id}", :query => options 25 | check_for_errors(res) 26 | res['response'] 27 | end 28 | 29 | # 30 | # translate/jobs (POST) 31 | # 32 | # Submits a job or group of jobs to translate. 33 | # 34 | def create(options = {}) 35 | res = self.post "/translate/jobs", :body => options 36 | check_for_errors(res) 37 | res['response'] 38 | end 39 | 40 | end 41 | end 42 | end -------------------------------------------------------------------------------- /spec/jobs_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Mugen::Jobs do 4 | before(:each) do 5 | Mugen.api_key = '6NO~NtyavKh@x-Uz@)0LG_PQ1KJI[(kd_2{oqv}H{ubO5Yu3is~IF^udRwM6QC6n' 6 | Mugen.private_key = 'w0F((zYj3=09(AD|2B7)jNT@5F[wajwk[6u^stF59wCfuCtwMEMB^c7y=5V~WM^K' 7 | @jobs = Mugen::Jobs 8 | end 9 | 10 | it "should retrieve jobs" do 11 | stats = @jobs.all 12 | stats.should be_a(Array) 13 | stats.should_not be_empty 14 | # TODO: any record should contain key 'job_id 15 | end 16 | 17 | # it "should retrieve jobs by group_id" do 18 | # balance = @jobs.by_group(1) 19 | # # balance.should be_a(Array) 20 | # # balance.should_not be_empty 21 | # end 22 | # 23 | # it "should create jobs" do 24 | # job = { 25 | # 'slug' => 'API Job lazy loading test', 26 | # 'body_src' => 'Where in the world is Carmen San Diego?', 27 | # 'lc_src' => 'en', 28 | # 'lc_tgt' => 'ja', 29 | # 'tier' => 'standard' 30 | # } 31 | # balance = @jobs.create(job) 32 | # end 33 | end -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Vladimir Penkin 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /lib/mugen/client.rb: -------------------------------------------------------------------------------- 1 | module Mugen 2 | class Client 3 | include HTTParty 4 | base_uri Mugen.api_url || 'http://api.sandbox.mygengo.com/v1/' 5 | headers = { 6 | 'Accept' => 'application/json', 7 | 'User-Agent' => 'myGengo Mugen Rails API Wrapper; Version 0.0.1; http://github.com/shell/mugen' 8 | } 9 | 10 | # debug_output $stderr 11 | 12 | def self.before_get(path, options) 13 | options[:query] = Mugen.set_params(options[:query]) if options.has_key? :query 14 | [path, options] 15 | end 16 | 17 | def self.before_post(path, options) 18 | options[:body] = Mugen.set_params(options[:body], :post) if options.has_key? :body 19 | [path, options] 20 | end 21 | 22 | def self.before_put(path, options) 23 | options[:body] = Mugen.set_params(options[:body], :post) if options.has_key? :body 24 | [path, options] 25 | end 26 | 27 | def self.check_for_errors(res) 28 | if res['opstat'] != 'ok' && res['err'] 29 | Mugen.errors << res['err']['msg'] 30 | end 31 | end 32 | end 33 | end -------------------------------------------------------------------------------- /generators/templates/public/stylesheets/mygengo/scaffold.css: -------------------------------------------------------------------------------- 1 | body { background-color: #fff; color: #333; } 2 | 3 | body, p, ol, ul, td { 4 | font-family: verdana, arial, helvetica, sans-serif; 5 | font-size: 13px; 6 | line-height: 18px; 7 | } 8 | 9 | pre { 10 | background-color: #eee; 11 | padding: 10px; 12 | font-size: 11px; 13 | } 14 | 15 | a { color: #000; } 16 | a:visited { color: #666; } 17 | a:hover { color: #fff; background-color:#000; } 18 | 19 | div.field, div.actions { 20 | margin-bottom: 10px; 21 | } 22 | 23 | #notice { 24 | color: green; 25 | } 26 | 27 | .field_with_errors { 28 | padding: 2px; 29 | background-color: red; 30 | display: table; 31 | } 32 | 33 | #error_explanation { 34 | width: 450px; 35 | border: 2px solid red; 36 | padding: 7px; 37 | padding-bottom: 0; 38 | margin-bottom: 20px; 39 | background-color: #f0f0f0; 40 | } 41 | 42 | #error_explanation h2 { 43 | text-align: left; 44 | font-weight: bold; 45 | padding: 5px 5px 5px 15px; 46 | font-size: 12px; 47 | margin: -7px; 48 | margin-bottom: 0px; 49 | background-color: #c00; 50 | color: #fff; 51 | } 52 | 53 | #error_explanation ul li { 54 | font-size: 12px; 55 | list-style: square; 56 | } 57 | -------------------------------------------------------------------------------- /lib/generators/mugen/templates/public/stylesheets/mygengo/scaffold.css: -------------------------------------------------------------------------------- 1 | body { background-color: #fff; color: #333; } 2 | 3 | body, p, ol, ul, td { 4 | font-family: verdana, arial, helvetica, sans-serif; 5 | font-size: 13px; 6 | line-height: 18px; 7 | } 8 | 9 | pre { 10 | background-color: #eee; 11 | padding: 10px; 12 | font-size: 11px; 13 | } 14 | 15 | a { color: #000; } 16 | a:visited { color: #666; } 17 | a:hover { color: #fff; background-color:#000; } 18 | 19 | div.field, div.actions { 20 | margin-bottom: 10px; 21 | } 22 | 23 | #notice { 24 | color: green; 25 | } 26 | 27 | .field_with_errors { 28 | padding: 2px; 29 | background-color: red; 30 | display: table; 31 | } 32 | 33 | #error_explanation { 34 | width: 450px; 35 | border: 2px solid red; 36 | padding: 7px; 37 | padding-bottom: 0; 38 | margin-bottom: 20px; 39 | background-color: #f0f0f0; 40 | } 41 | 42 | #error_explanation h2 { 43 | text-align: left; 44 | font-weight: bold; 45 | padding: 5px 5px 5px 15px; 46 | font-size: 12px; 47 | margin: -7px; 48 | margin-bottom: 0px; 49 | background-color: #c00; 50 | color: #fff; 51 | } 52 | 53 | #error_explanation ul li { 54 | font-size: 12px; 55 | list-style: square; 56 | } 57 | -------------------------------------------------------------------------------- /spec/job_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Mugen::Job do 4 | before(:each) do 5 | Mugen.api_key = '6NO~NtyavKh@x-Uz@)0LG_PQ1KJI[(kd_2{oqv}H{ubO5Yu3is~IF^udRwM6QC6n' 6 | Mugen.private_key = 'w0F((zYj3=09(AD|2B7)jNT@5F[wajwk[6u^stF59wCfuCtwMEMB^c7y=5V~WM^K' 7 | @job = Mugen::Job 8 | @jobs = Mugen::Jobs.all 9 | end 10 | 11 | it "should retrieve job" do 12 | job = @job.find(@jobs.first['job_id']) 13 | job.should be_a(Hash) 14 | job['job_id'].should == @jobs.first['job_id'] 15 | end 16 | 17 | it "should retrieve job" do 18 | job = @job.preview(@jobs.first['job_id']) 19 | # TODO: raw jpeg stream 20 | end 21 | 22 | 23 | 24 | # it "should retrieve jobs by group_id" do 25 | # balance = @jobs.by_group(1) 26 | # # balance.should be_a(Array) 27 | # # balance.should_not be_empty 28 | # end 29 | # 30 | # it "should create jobs" do 31 | # job = { 32 | # 'slug' => 'API Job lazy loading test', 33 | # 'body_src' => 'Where in the world is Carmen San Diego?', 34 | # 'lc_src' => 'en', 35 | # 'lc_tgt' => 'ja', 36 | # 'tier' => 'standard' 37 | # } 38 | # balance = @jobs.create(job) 39 | # end 40 | end -------------------------------------------------------------------------------- /mugen.gemspec: -------------------------------------------------------------------------------- 1 | # coding: UTF-8 2 | $LOAD_PATH << File.join(File.dirname(__FILE__), 'lib') 3 | require 'mugen/version' 4 | Gem::Specification.new do |s| 5 | s.name = "mugen" 6 | s.version = Mugen::VERSION 7 | s.platform = Gem::Platform::RUBY 8 | s.authors = ["Vladimir Penkin"] 9 | s.email = ["penkinv@gmail.com"] 10 | s.homepage = "http://github.com/shell/mugen" 11 | s.summary = "MyGengo API wrapper" 12 | s.description = "MyGengo API wrapper(http://mygengo.com/services/api/dev-docs/)" 13 | s.rubyforge_project = s.name 14 | 15 | s.required_rubygems_version = ">= 1.3.6" 16 | 17 | s.add_runtime_dependency 'activesupport' 18 | s.add_runtime_dependency 'httparty' 19 | s.add_runtime_dependency 'haml' 20 | s.add_runtime_dependency 'ruby-hmac' 21 | 22 | s.add_development_dependency "rspec" 23 | 24 | # The list of files to be contained in the gem 25 | s.files = `git ls-files`.split("\n") 26 | # s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact 27 | # s.extensions = `git ls-files ext/extconf.rb`.split("\n") 28 | 29 | s.require_path = 'lib' 30 | 31 | # For C extensions 32 | # s.extensions = "ext/extconf.rb" 33 | end 34 | -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/views/mygengo/jobs/reject_form.haml: -------------------------------------------------------------------------------- 1 | %h3 Rejection form 2 | = form_for :job, :url => {:action => 'reject', :id => @job['job_id']} do |f| 3 | .field 4 | Job ##{link_to @job['job_id'], mygengo_job_path(@job['job_id'])} 5 | .field 6 | Whould you like to cancel the translation? 7 | %br 8 | = radio_button_tag 'job[follow_up]', 'cancel' 9 | Yes, please cancel and refund me 10 | %br 11 | = radio_button_tag 'job[follow_up]', 'requeue' 12 | No, please have another translator finish the job 13 | .field 14 | Rejection reason 15 | %br 16 | = radio_button_tag 'job[reason]', 'quality' 17 | Poor quality of translation 18 | %br 19 | = radio_button_tag 'job[reason]', 'missing' 20 | Missing of incomplete translation 21 | %br 22 | = radio_button_tag 'job[reason]', 'missing' 23 | Other (please describe beliw) 24 | .field 25 | Comment 26 | %br 27 | = text_area_tag 'job[comment]', '', :size => '40x2' 28 | - if (@job['captcha_url'] && !@job['captcha_url'].empty?) 29 | .field 30 | = image_tag @job['captcha_url'] 31 | %br 32 | = text_field_tag 'job[captcha]' 33 | 34 | = f.submit "Reject translation" 35 | | 36 | = link_to :back -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/views/mygengo/jobs/show.haml: -------------------------------------------------------------------------------- 1 | .mygengo-job 2 | %h2 Job: #{@job['job_id']}(#{@job['slug']}) 3 | 4 | %table.general 5 | = render :partial => 'mygengo/jobs/job', :locals => {:job => @job} 6 | 7 | .mygengo-form 8 | .left 9 | Body 10 | %br 11 | = text_area_tag :body_src, @job['body_src'], :size => '40x11' 12 | %br 13 | - if @job['status'] == 'pending' || @job['status'] == 'approved' 14 | %div 15 | Body (translated) 16 | %br 17 | = text_area_tag :body_tgt, @job['body_tgt'], :size => '40x10' 18 | - if @job['status'] == 'pending' 19 | %br 20 | Warning: this is machine pre-translation 21 | .clear 22 | - unless @feedback.blank? 23 | = render :partial => "mygengo/jobs/feedback", :locals => {:feedback => @feedback} 24 | 25 | %br 26 | 27 | - unless @job['status'] == 'available' || @job['status'] == 'approved' 28 | .mygengo-box 29 | = render :partial => "comments", :locals => {:comments => @comments} 30 | = render :partial => "mygengo/comments/form" 31 | 32 | 33 | - unless @revisions.empty? 34 | .mygengo-box 35 | %h4 Revisions 36 | %ul.mygengo-revisions 37 | - for rev in @revisions 38 | = render :partial => "mygengo/jobs/revision", :locals => {:revision => rev, :job => @job} -------------------------------------------------------------------------------- /generators/USAGE: -------------------------------------------------------------------------------- 1 | Description: 2 | Generates MyGengo scaffold for your app 3 | 4 | Example: 5 | script/generate mugen 6 | 7 | This will update routes.rb 8 | This will create: 9 | config/initializers/mugen.rb 10 | app/controllers/mygengo 11 | app/controllers/mygengo/account_controller.rb 12 | app/controllers/mygengo/comments_controller.rb 13 | app/controllers/mygengo/jobs_controller.rb 14 | app/helpers/mugen_helper.rb 15 | app/views/layouts/mygengo.html.erb 16 | app/views/mygengo/account 17 | app/views/mygengo/comments 18 | app/views/mygengo/jobs 19 | app/views/mygengo/account/index.haml 20 | app/views/mygengo/account/_balance.haml 21 | app/views/mygengo/account/_stats.haml 22 | app/views/mygengo/comments/_comment.haml 23 | app/views/mygengo/comments/_form.haml 24 | app/views/mygengo/jobs/_comments.haml 25 | app/views/mygengo/jobs/_feedback.haml 26 | app/views/mygengo/jobs/_revision.haml 27 | app/views/mygengo/jobs/index.haml 28 | app/views/mygengo/jobs/new.haml 29 | app/views/mygengo/jobs/reject_form.haml 30 | app/views/mygengo/jobs/review_form.haml 31 | app/views/mygengo/jobs/revise_form.haml 32 | app/views/mygengo/jobs/revision.haml 33 | app/views/mygengo/jobs/show.haml 34 | README -------------------------------------------------------------------------------- /lib/generators/mugen/USAGE: -------------------------------------------------------------------------------- 1 | Description: 2 | Generates MyGengo scaffold for your app 3 | 4 | Example: 5 | rails generate mugen 6 | 7 | This will update routes.rb 8 | This will create: 9 | config/initializers/mugen.rb 10 | app/controllers/mygengo 11 | app/controllers/mygengo/account_controller.rb 12 | app/controllers/mygengo/comments_controller.rb 13 | app/controllers/mygengo/jobs_controller.rb 14 | app/helpers/mugen_helper.rb 15 | app/views/layouts/mygengo.html.erb 16 | app/views/mygengo/account 17 | app/views/mygengo/comments 18 | app/views/mygengo/jobs 19 | app/views/mygengo/account/index.haml 20 | app/views/mygengo/account/_balance.haml 21 | app/views/mygengo/account/_stats.haml 22 | app/views/mygengo/comments/_comment.haml 23 | app/views/mygengo/comments/_form.haml 24 | app/views/mygengo/jobs/_comments.haml 25 | app/views/mygengo/jobs/_feedback.haml 26 | app/views/mygengo/jobs/_revision.haml 27 | app/views/mygengo/jobs/index.haml 28 | app/views/mygengo/jobs/new.haml 29 | app/views/mygengo/jobs/reject_form.haml 30 | app/views/mygengo/jobs/review_form.haml 31 | app/views/mygengo/jobs/revise_form.haml 32 | app/views/mygengo/jobs/revision.haml 33 | app/views/mygengo/jobs/show.haml 34 | README 35 | 36 | -------------------------------------------------------------------------------- /lib/generators/mugen/mugen_generator.rb: -------------------------------------------------------------------------------- 1 | class MugenGenerator < Rails::Generators::Base 2 | source_root File.expand_path('../templates', __FILE__) 3 | 4 | def install 5 | # Create directories 6 | %W( 7 | app/controllers/mygengo 8 | app/views/mygengo/account 9 | app/views/mygengo/comments 10 | app/views/mygengo/jobs 11 | public/stylesheets/mygengo 12 | public/images/mygengo 13 | ).each {|dir| 14 | directory dir 15 | } 16 | 17 | # Copy files 18 | %W( 19 | config/initializers/mugen.rb 20 | app/helpers/mugen_helper.rb 21 | app/views/layouts/mygengo.html.erb 22 | ).each do |filename| 23 | copy_file filename, filename 24 | end 25 | 26 | # Add routes 27 | sentinel = '::Application.routes.draw do' 28 | new_routes = IO.read(File.dirname(__FILE__) + '/templates/config/routes3.rb') 29 | 30 | gsub_file 'config/routes3.rb', /(#{Regexp.escape(sentinel)})/mi do |match| 31 | "#{match}\n #{new_routes}" 32 | end 33 | 34 | 35 | 36 | puts MugenGenerator.description 37 | end 38 | 39 | def self.description 40 | <<-DESCRIPTION 41 | ******************************************************************* 42 | MyGengo scaffold complete 43 | 44 | 45 | ******************************************************************* 46 | DESCRIPTION 47 | end 48 | desc(description) 49 | 50 | end -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/views/mygengo/jobs/new.haml: -------------------------------------------------------------------------------- 1 | %h3 New translation order 2 | = form_for :job, :url => {:action => 'create'}, :html => {:class => 'mygengo-form'} do |f| 3 | .field 4 | Slug 5 | %br 6 | = f.text_field :slug 7 | .float 8 | .field 9 | Text 10 | %br 11 | = f.text_area :body_src 12 | %div 13 | .field.float 14 | Translate from 15 | %br 16 | = f.select :lc_src, @language_src, :selected => 'en' 17 | .field 18 | Translate to 19 | %br 20 | = f.select :lc_tgt, @language_tgt 21 | .field 22 | Tier 23 | %br 24 | = f.radio_button :tier, :machine 25 | Machine 26 | = f.radio_button:tier, :standard 27 | Standard 28 | = f.radio_button :tier, :pro 29 | Pro 30 | = f.radio_button :tier, :ultra 31 | Ultra 32 | #comment_area.hidden 33 | Comment 34 | %br 35 | = f.text_area :comment, :size => '40x7' 36 | #comment_button.field 37 | = button_to_function 'Add comment' do |page| 38 | - page['#comment_area'].show 39 | - page['#comment_button'].hide 40 | 41 | .field 42 | = f.check_box :as_group 43 | As group 44 | .field 45 | = f.check_box :auto_approve 46 | Auto approve and publish jobs 47 | / .field 48 | / %h4 Total (250 words) 49 | / $10.50 50 | .field 51 | = f.submit "Order" 52 | 53 | .clear -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/views/mygengo/jobs/review_form.haml: -------------------------------------------------------------------------------- 1 | %h3 Job review page 2 | = form_for :job, :url => {:action => 'approve', :id => @job['job_id']} do |f| 3 | .field 4 | Job ##{link_to @job['job_id'], mygengo_job_path(@job['job_id'])} 5 | .field 6 | %h4 7 | Original text 8 | %br 9 | = text_area_tag :body_src, @job['body_src'], :size => '40x7' 10 | .field 11 | %h4 12 | Preview 13 | %br 14 | = image_tag @preview, :title => "translation preview" 15 | 16 | .field 17 | Please rate the translation 18 | %br 19 | Bad 20 | = radio_button_tag 'job[rating]', 1 21 | 1 22 | = radio_button_tag 'job[rating]', 2 23 | 2 24 | = radio_button_tag 'job[rating]', 3 25 | 3 26 | = radio_button_tag 'job[rating]', 4 27 | 4 28 | = radio_button_tag 'job[rating]', 5 29 | 5 30 | Good 31 | .field 32 | for_translator 33 | %br 34 | = text_area_tag 'job[for_translator]', '', :size => '40x2' 35 | .field 36 | for_mygengo 37 | %br 38 | = text_area_tag 'job[for_mygengo]', '', :size => '40x2' 39 | 40 | .field 41 | Can myGengo use this translation publicly in its examples? 42 | %br 43 | = check_box_tag 'job[public]', '1' 44 | Yes, you can use this translation as public example of myGengo service. 45 | 46 | .mygengo-box 47 | = render :partial => "comments", :locals => {:comments => @comments} 48 | 49 | 50 | = f.submit "Approve" 51 | | 52 | = link_to 'Reject', reject_form_mygengo_job_path(@job['job_id']) 53 | | 54 | = link_to 'Request corrections', revise_form_mygengo_job_path(@job['job_id']) -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/views/layouts/mygengo.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | MyGengo 5 | <%= stylesheet_link_tag "mygengo/base", "mygengo/style", "mygengo/override", :cache => true %> 6 | <%= stylesheet_link_tag 'mygengo/scaffold', 'mygengo/mugen', :cache => true %> 7 | <%= javascript_include_tag 'jquery', 'rails', 'application' %> 8 | <%= csrf_meta_tag %> 9 | 10 | 11 |
12 | 26 |
27 |
28 | <% flash.each do |type, message| -%> 29 | <% unless message.empty? %> 30 |
31 |

<%= message %>

32 |
33 | <% end %> 34 | <% end -%> 35 |
36 |
37 | <%= yield %> 38 |
39 |
40 | 45 |
46 | 49 |
50 |
51 | 52 | 53 | -------------------------------------------------------------------------------- /lib/mugen.rb: -------------------------------------------------------------------------------- 1 | require 'active_support' 2 | require 'cgi' 3 | require 'hmac-sha1' 4 | require 'httparty' 5 | require 'mugen/core_extensions' 6 | require 'mugen/httparty_extensions' 7 | 8 | module Mugen 9 | extend self 10 | 11 | autoload :Client, 'mugen/client' 12 | autoload :Account, 'mugen/account' 13 | autoload :Service, 'mugen/service' 14 | autoload :Jobs, 'mugen/jobs' 15 | autoload :Job, 'mugen/job' 16 | 17 | @@errors = [] 18 | 19 | def api_url=(url) 20 | @api_url = url 21 | end 22 | 23 | def api_url 24 | @api_url || 'http://api.sandbox.mygengo.com/v1/' 25 | end 26 | 27 | def api_key=(key) 28 | @api_key = key 29 | end 30 | 31 | def api_key 32 | @api_key or raise "API_KEY is not specified" 33 | end 34 | 35 | def private_key=(key) 36 | @private_key = key 37 | end 38 | 39 | def private_key 40 | @private_key or raise "PRIVATE_KEY is not specified" 41 | end 42 | 43 | def errors 44 | @@errors || [] 45 | end 46 | 47 | def sign(private_key, data) 48 | if Hash === data 49 | sorted_keys = data.keys.sort 50 | data = sorted_keys.zip(data.values_at(*sorted_keys)).map {|k, v| 51 | "#{k}=#{CGI::escape(v.to_s)}" 52 | } * '&' 53 | end 54 | 55 | HMAC::SHA1.hexdigest private_key, data 56 | end 57 | 58 | def set_params(options = {}, method = :get) 59 | params = ActiveSupport::OrderedHash.new 60 | params.merge! '_method' => 'post' if method == :post 61 | params.merge! 'api_key' => Mugen.api_key 62 | params.merge! 'data' => options.to_json unless options.empty? 63 | params.merge! 'ts' => Time.now.gmtime.to_i.to_s 64 | if method == :get 65 | params.merge! 'api_sig' => sign(Mugen.private_key, params) 66 | else 67 | params.merge! 'api_sig' => sign(Mugen.private_key, params.to_json.gsub('/', '\/')) 68 | end 69 | 70 | params 71 | end 72 | 73 | end -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mugen [![Build Status](https://secure.travis-ci.org/shell/mugen.png)](https://secure.travis-ci.org/shell/mugen.png) [![Code Climate](https://codeclimate.com/github/shell/mugen.png)](https://codeclimate.com/github/shell/mugen) 2 | ## Introduction 3 | Mugen is API wrapper for MyGengo() and scaffold generator for existing rails app 4 | 5 | ## Installation 6 | Working best with Rails3 and jQuery 7 | 8 | ## Rails 3.x 9 | 10 | Add gems to your Gemfile and bundle install it: 11 | gem 'haml' 12 | gem 'mugen' 13 | 14 | Generate scaffold: 15 | $ rails generate mugen 16 | 17 | Install rails3_before_render plugin 18 | $ rails plugin install git://github.com/shell/rails3_before_render.git 19 | 20 | Configure API keys in config/initializers/mugen.rb: 21 | Mugen.api_key = '' 22 | Mugen.private_key = '' 23 | 24 | Start server and enjoy 25 | 26 | ## Rails 2.x 27 | Add gems to config/environment.rb 28 | config.gem 'haml' 29 | config.gem 'mugen' 30 | 31 | Next install gems via 32 | gem install mugen 33 | or 34 | rake gems:install 35 | 36 | Next generate scaffold 37 | 38 | $ script/generate mugen 39 | 40 | Install rails3_before_render plugin 41 | $ rails plugin install git://github.com/shell/rails3_before_render.git 42 | 43 | Configure API keys in config/initializers/mugen.rb 44 | Start server and enjoy 45 | 46 | ## Usage 47 | See routes.rb for url mappings. 48 | Default page is here () 49 | 50 | ## Debugging 51 | 52 | To debug http-requests, uncomment following line in lib/mugen/client.rb: 53 | 54 | debug_output $stderr 55 | 56 | ## TODO 57 | - remove csrf_tag in layout file for rails2 58 | - I18n 59 | - made js agnostic 60 | - cover everything with tests 61 | - Something really bad happening with css 62 | 63 | 64 | ## Author 65 | Copyright (c) 2011 Vladimir Penkin 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /generators/templates/public/stylesheets/mygengo/mugen.css: -------------------------------------------------------------------------------- 1 | .mygengo-box { 2 | border: 1px dashed #000; 3 | margin: 5px; 4 | padding: 5px 0px 5px 15px; 5 | width: 400px; 6 | } 7 | 8 | .hidden { 9 | display: none; 10 | } 11 | 12 | .clear { 13 | clear: all; 14 | } 15 | 16 | .mygengo-form { 17 | 18 | } 19 | 20 | .mygengo-form div{ 21 | } 22 | 23 | .mygengo-form div.float{ 24 | float: left; 25 | margin-right: 15px; 26 | } 27 | .mygengo-form div.left{ 28 | float: left; 29 | margin-right: 15px; 30 | } 31 | 32 | 33 | .mygento-comments { 34 | 35 | } 36 | 37 | .mygengo-revisions { 38 | 39 | } 40 | 41 | table td { 42 | padding: 6px 6px; 43 | border-bottom: 1px solid #cccccc; 44 | font-size: 1em; 45 | line-height: 1.4em; 46 | vertical-align: top; 47 | } 48 | 49 | .general { 50 | margin: 1.4em 0; } 51 | .general h2 { 52 | font-size: 1.1em; 53 | margin: 0; } 54 | 55 | table.general { 56 | width: 100%; 57 | margin: 0.5em auto 1em auto; 58 | border-top: 1px solid #cccccc; 59 | background: white; } 60 | table.general thead th { 61 | font-weight: normal; 62 | font-size: 0.95em; 63 | line-height: 1em; 64 | padding: 4px 6px; 65 | border-bottom: 1px solid #cccccc; 66 | background-color: #dddddd; 67 | page-break-before: auto; 68 | white-space: nowrap; 69 | text-align: left; } 70 | table.general thead th.right_align { 71 | text-align: right; } 72 | table.general thead th a { 73 | color: #006699; 74 | text-decoration: none; 75 | border: 0; } 76 | table.general thead.tabular th { 77 | font-weight: normal; 78 | font-size: 9px; 79 | text-transform: uppercase; 80 | line-height: 1em; 81 | padding: 5px 6px; 82 | background-color: #dddddd; } 83 | table.general thead.tabular th.flag_label { 84 | padding: 5px 2px; } 85 | table.general tr.highlight { 86 | background-color: #ecf7ff; 87 | cursor: pointer; } 88 | table.general tr.normal { 89 | background: transparent; } 90 | table.general td { 91 | padding: 6px 6px; 92 | border-bottom: 1px solid #cccccc; 93 | font-size: 1em; 94 | line-height: 1.4em; 95 | vertical-align: top; } 96 | table.general td.grouping_header { 97 | font-weight: bold; 98 | font-size: 0.9em; 99 | line-height: 1.1em; 100 | padding: 4px 6px; 101 | border-bottom: 1px solid #cccccc; 102 | color: #999999; 103 | background-color: #f6f6f6; } 104 | table.general td.header { 105 | padding: 0.4em 0.5em; 106 | vertical-align: bottom; 107 | border-bottom: 1px solid #cccccc; 108 | background-color: #eeeeee; } 109 | table.general td.right_align { 110 | text-align: right; 111 | white-space: nowrap; } 112 | table.general td.upper { 113 | text-transform: uppercase; } 114 | table.general tbody td.grouping_header { 115 | padding: 6px; } 116 | table.general tfoot td { 117 | border: 0; } 118 | -------------------------------------------------------------------------------- /lib/generators/mugen/templates/public/stylesheets/mygengo/mugen.css: -------------------------------------------------------------------------------- 1 | .mygengo-box { 2 | border: 1px dashed #000; 3 | margin: 5px; 4 | padding: 5px 0px 5px 15px; 5 | width: 400px; 6 | } 7 | 8 | .hidden { 9 | display: none; 10 | } 11 | 12 | .clear { 13 | clear: all; 14 | } 15 | 16 | .mygengo-form { 17 | 18 | } 19 | 20 | .mygengo-form div{ 21 | } 22 | 23 | .mygengo-form div.float{ 24 | float: left; 25 | margin-right: 15px; 26 | } 27 | .mygengo-form div.left{ 28 | float: left; 29 | margin-right: 15px; 30 | } 31 | 32 | 33 | .mygento-comments { 34 | 35 | } 36 | 37 | .mygengo-revisions { 38 | 39 | } 40 | 41 | table td { 42 | padding: 6px 6px; 43 | border-bottom: 1px solid #cccccc; 44 | font-size: 1em; 45 | line-height: 1.4em; 46 | vertical-align: top; 47 | } 48 | 49 | .general { 50 | margin: 1.4em 0; } 51 | .general h2 { 52 | font-size: 1.1em; 53 | margin: 0; } 54 | 55 | table.general { 56 | width: 100%; 57 | margin: 0.5em auto 1em auto; 58 | border-top: 1px solid #cccccc; 59 | background: white; } 60 | table.general thead th { 61 | font-weight: normal; 62 | font-size: 0.95em; 63 | line-height: 1em; 64 | padding: 4px 6px; 65 | border-bottom: 1px solid #cccccc; 66 | background-color: #dddddd; 67 | page-break-before: auto; 68 | white-space: nowrap; 69 | text-align: left; } 70 | table.general thead th.right_align { 71 | text-align: right; } 72 | table.general thead th a { 73 | color: #006699; 74 | text-decoration: none; 75 | border: 0; } 76 | table.general thead.tabular th { 77 | font-weight: normal; 78 | font-size: 9px; 79 | text-transform: uppercase; 80 | line-height: 1em; 81 | padding: 5px 6px; 82 | background-color: #dddddd; } 83 | table.general thead.tabular th.flag_label { 84 | padding: 5px 2px; } 85 | table.general tr.highlight { 86 | background-color: #ecf7ff; 87 | cursor: pointer; } 88 | table.general tr.normal { 89 | background: transparent; } 90 | table.general td { 91 | padding: 6px 6px; 92 | border-bottom: 1px solid #cccccc; 93 | font-size: 1em; 94 | line-height: 1.4em; 95 | vertical-align: top; } 96 | table.general td.grouping_header { 97 | font-weight: bold; 98 | font-size: 0.9em; 99 | line-height: 1.1em; 100 | padding: 4px 6px; 101 | border-bottom: 1px solid #cccccc; 102 | color: #999999; 103 | background-color: #f6f6f6; } 104 | table.general td.header { 105 | padding: 0.4em 0.5em; 106 | vertical-align: bottom; 107 | border-bottom: 1px solid #cccccc; 108 | background-color: #eeeeee; } 109 | table.general td.right_align { 110 | text-align: right; 111 | white-space: nowrap; } 112 | table.general td.upper { 113 | text-transform: uppercase; } 114 | table.general tbody td.grouping_header { 115 | padding: 6px; } 116 | table.general tfoot td { 117 | border: 0; } 118 | -------------------------------------------------------------------------------- /generators/mugen_generator.rb: -------------------------------------------------------------------------------- 1 | class MugenGenerator < Rails::Generator::Base 2 | attr_reader :model_name 3 | 4 | def initialize(runtime_args, runtime_options = {}) 5 | runtime_args << "user" if runtime_args.empty? 6 | super 7 | end 8 | 9 | def manifest 10 | record do |m| 11 | 12 | # Initializer 13 | m.file 'config/initializers/mugen.rb', 'config/initializers/mugen.rb' 14 | 15 | # Controller 16 | m.directory 'app/controllers/mygengo' 17 | m.file "app/controllers/mygengo/account_controller.rb", "app/controllers/mygengo/account_controller.rb" 18 | m.file "app/controllers/mygengo/comments_controller.rb", "app/controllers/mygengo/comments_controller.rb" 19 | m.file "app/controllers/mygengo/jobs_controller.rb", "app/controllers/mygengo/jobs_controller.rb" 20 | 21 | # Helpers 22 | m.file "app/helpers/mugen_helper.rb", "app/helpers/mugen_helper.rb" 23 | 24 | # Views 25 | m.file 'app/views/layouts/mygengo.html.erb', 'app/views/layouts/mygengo.html.erb' 26 | m.directory 'app/views/mygengo/account' 27 | m.directory 'app/views/mygengo/comments' 28 | m.directory 'app/views/mygengo/jobs' 29 | m.directory 'public/stylesheets/mygengo' 30 | m.directory 'public/images/mygengo' 31 | m.file 'app/views/mygengo/account/index.haml', 'app/views/mygengo/account/index.haml' 32 | m.file 'app/views/mygengo/account/_balance.haml', 'app/views/mygengo/account/_balance.haml' 33 | m.file 'app/views/mygengo/account/_stats.haml', 'app/views/mygengo/account/_stats.haml' 34 | m.file 'app/views/mygengo/comments/_comment.haml', 'app/views/mygengo/comments/_comment.haml' 35 | m.file 'app/views/mygengo/comments/_form.haml', 'app/views/mygengo/comments/_form.haml' 36 | m.file 'app/views/mygengo/jobs/_comments.haml', 'app/views/mygengo/jobs/_comments.haml' 37 | m.file 'app/views/mygengo/jobs/_feedback.haml', 'app/views/mygengo/jobs/_feedback.haml' 38 | m.file 'app/views/mygengo/jobs/_job.haml', 'app/views/mygengo/jobs/_job.haml' 39 | m.file 'app/views/mygengo/jobs/_revision.haml', 'app/views/mygengo/jobs/_revision.haml' 40 | m.file 'app/views/mygengo/jobs/index.haml', 'app/views/mygengo/jobs/index.haml' 41 | m.file 'app/views/mygengo/jobs/new.haml', 'app/views/mygengo/jobs/new.haml' 42 | m.file 'app/views/mygengo/jobs/reject_form.haml', 'app/views/mygengo/jobs/reject_form.haml' 43 | m.file 'app/views/mygengo/jobs/review_form.haml', 'app/views/mygengo/jobs/review_form.haml' 44 | m.file 'app/views/mygengo/jobs/revise_form.haml', 'app/views/mygengo/jobs/revise_form.haml' 45 | m.file 'app/views/mygengo/jobs/revision.haml', 'app/views/mygengo/jobs/revision.haml' 46 | m.file 'app/views/mygengo/jobs/show.haml', 'app/views/mygengo/jobs/show.haml' 47 | m.file 'public/stylesheets/mygengo/base.css', 'public/stylesheets/mygengo/base.css' 48 | m.file 'public/stylesheets/mygengo/mugen.css', 'public/stylesheets/mygengo/mugen.css' 49 | m.file 'public/stylesheets/mygengo/override.css', 'public/stylesheets/mygengo/override.css' 50 | m.file 'public/stylesheets/mygengo/scaffold.css', 'public/stylesheets/mygengo/scaffold.css' 51 | m.file 'public/stylesheets/mygengo/style.css', 'public/stylesheets/mygengo/style.css' 52 | # m.readme "USAGE" 53 | 54 | # Routes 55 | sentinel = 'ActionController::Routing::Routes.draw do |map|' 56 | new_routes = IO.read(File.dirname(__FILE__) + '/templates/config/routes.rb') 57 | 58 | m.gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match| 59 | "#{match}\n #{new_routes}" 60 | end 61 | end 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /lib/generators/mugen/templates/app/controllers/mygengo/jobs_controller.rb: -------------------------------------------------------------------------------- 1 | class Mygengo::JobsController < Mygengo::MygengoController 2 | URL_REGEXP = /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix 3 | 4 | # GET /jobs 5 | # GET /jobs.xml 6 | def index 7 | @job_ids = Mugen::Jobs.all 8 | if @job_ids 9 | @jobs = @job_ids.collect {|j| 10 | Mugen::Job.find(j['job_id']).merge('comments' => Mugen::Job.comments(j['job_id'])) 11 | } 12 | respond_to do |format| 13 | format.html # index.html.erb 14 | format.xml { render :xml => @jobs } 15 | end 16 | else 17 | redirect_to mygengo_account_index_path 18 | end 19 | end 20 | 21 | # GET /jobs/1 22 | # GET /jobs/1.xml 23 | def show 24 | @job = Mugen::Job.find(params[:id]) 25 | @preview = Mugen::Job.preview(@job['job_id']) 26 | @comments = Mugen::Job.comments(@job['job_id']) 27 | @job.merge!('comments' => @comments) 28 | @feedback = Mugen::Job.feedback(@job['job_id']) 29 | @revisions = Mugen::Job.revisions(@job['job_id']) 30 | @revisions = [@revisions] if @revisions.is_a?(Hash) 31 | 32 | respond_to do |format| 33 | format.html # show.html.erb 34 | format.xml { render :xml => @job } 35 | end 36 | end 37 | 38 | def review_form 39 | @job = Mugen::Job.find(params[:id]) 40 | @preview = Mugen::Job.preview(@job['job_id']) 41 | @comments = Mugen::Job.comments(@job['job_id']) 42 | @job.merge!('comments' => @comments) 43 | @feedback = Mugen::Job.feedback(@job['job_id']) 44 | end 45 | 46 | def reject_form 47 | @job = Mugen::Job.find(params[:id]) 48 | @preview = Mugen::Job.preview(@job['job_id']) 49 | @comments = Mugen::Job.comments(@job['job_id']) 50 | @job.merge!('comments' => @comments) 51 | end 52 | 53 | def revise_form 54 | @job = Mugen::Job.find(params[:id]) 55 | @preview = Mugen::Job.preview(@job['job_id']) 56 | @comments = Mugen::Job.comments(@job['job_id']) 57 | @job.merge!('comments' => @comments) 58 | end 59 | 60 | # GET /jobs/1 61 | # GET /jobs/1.xml 62 | def revision 63 | @job = Mugen::Job.find(params[:job_id]) 64 | @revision = Mugen::Job.revision(params[:job_id], params[:id]) 65 | 66 | respond_to do |format| 67 | format.html {} 68 | format.xml { render :xml => @job } 69 | end 70 | end 71 | 72 | # GET /jobs/new 73 | # GET /jobs/new.xml 74 | def new 75 | @job = Mugen::Job 76 | @languages = Mugen::Service.languages 77 | @language_pairs = Mugen::Service.language_pairs 78 | @language_src = @languages.collect { |lp| [ lp["language"], lp['lc'] ] }.uniq.sort 79 | @language_tgt = @languages.collect { |lp| [ lp["language"], lp['lc'] ] }.uniq.sort 80 | 81 | respond_to do |format| 82 | format.html # new.html.erb 83 | format.xml { render :xml => @job } 84 | end 85 | end 86 | 87 | # GET /jobs/1/edit 88 | def edit 89 | @job = Mugen::Job.find(params[:id]) 90 | end 91 | 92 | # POST /jobs 93 | # POST /jobs.xml 94 | def create 95 | params[:job]['body_src'] = sanitize(params[:job]['body_src']) 96 | if params[:job]['callback_url'].empty? || 97 | !params[:job]['callback_url'].match(URL_REGEXP) 98 | params[:job].delete('callback_url') 99 | end 100 | flag = Mugen::Job.create(params[:job]) 101 | 102 | redirect_to mygengo_jobs_path 103 | end 104 | 105 | # PUT /jobs/1 106 | # PUT /jobs/1.xml 107 | def update 108 | @job = Mugen::Job.update(params[:id]) 109 | 110 | redirect_to mygengo_jobs_path 111 | end 112 | 113 | def purchase 114 | @job = Mugen::Job.purchase(params[:id]) 115 | 116 | redirect_to mygengo_jobs_path 117 | end 118 | 119 | def approve 120 | @job = Mugen::Job.approve(params[:id]) 121 | 122 | redirect_to mygengo_jobs_path 123 | end 124 | 125 | def revise 126 | @job = Mugen::Job.revise(params[:id], params[:job]) 127 | 128 | redirect_to mygengo_jobs_path 129 | end 130 | 131 | def reject 132 | @job = Mugen::Job.reject(params[:id], params[:job]) 133 | 134 | redirect_to mygengo_jobs_path 135 | end 136 | 137 | # DELETE /jobs/1 138 | # DELETE /jobs/1.xml 139 | def destroy 140 | @job = Mugen::Job.delete(params[:id]) 141 | 142 | respond_to do |format| 143 | format.html { redirect_to(mygengo_jobs_url) } 144 | format.xml { head :ok } 145 | end 146 | end 147 | 148 | private 149 | 150 | def sanitize(text) 151 | return text.gsub(/<\/?.*?>/, "") 152 | end 153 | end -------------------------------------------------------------------------------- /lib/mugen/job.rb: -------------------------------------------------------------------------------- 1 | require 'tempfile' 2 | module Mugen 3 | class Job < Client 4 | class << self 5 | 6 | attr_accessor :job_id, :slug, :body_src, :body_tgt, :lc_src, :lc_tgt, 7 | :unit_count, :tier, :credits, :status, :capcha_url, 8 | :eta, :callback_url, :auto_approve, :ctime, :custom_data, 9 | :mt, :comment, :as_group 10 | 11 | 12 | 13 | # 14 | # translate/job/{id} (GET) 15 | # 16 | # Retrieves a specific job 17 | # 18 | def find(id, options={}) 19 | res = self.get "/translate/job/#{id}", :query => options 20 | check_for_errors(res) 21 | res['response']['job'] 22 | end 23 | 24 | # 25 | # translate/job (POST) 26 | # 27 | # Post a new job for translation 28 | # 29 | def create(options = {}) 30 | if options.nil? || options.empty? 31 | raise Exception, '"options" missing required parameters' 32 | end 33 | job = { 'job' => options } 34 | res = self.post "/translate/job", :body => job 35 | check_for_errors(res) 36 | res['response'] 37 | end 38 | 39 | # 40 | # translate/job/{id} (PUT) 41 | # 42 | # Updates a job to translate. 43 | # 44 | def update(job_id, action, options = {}) 45 | # if options.nil? || options.empty? 46 | # raise Exception, '"options" missing required parameters' 47 | # end 48 | options.merge! :action => action 49 | job = options 50 | res = self.put "/translate/job/#{job_id}", :body => job 51 | check_for_errors(res) 52 | res['response'] 53 | end 54 | 55 | def purchase(job_id, options = {}) 56 | update(job_id, 'purchase', options) 57 | end 58 | 59 | def revise(job_id, options = {}) 60 | update(job_id, 'revise', options) 61 | end 62 | 63 | def approve(job_id, options = {}) 64 | update(job_id, 'approve', options) 65 | end 66 | 67 | def reject(job_id, options = {}) 68 | update(job_id, 'reject', options) 69 | end 70 | 71 | # 72 | # translate/job/{id} (DELETE) 73 | # 74 | # Cancels the job. You can only cancel a job if it has not been 75 | # started already by a translator. 76 | # 77 | def delete(id, options = {}) 78 | options.merge!('_method' => 'delete') 79 | res = self.delete "/translate/job/#{id}", :query => options 80 | check_for_errors(res) 81 | res['response'] 82 | end 83 | 84 | # 85 | # translate/job/{id}/preview (GET) 86 | # 87 | # Renders a JPEG preview of the translated text 88 | # N.B. - if the request is valid, a raw JPEG stream is returned. 89 | # 90 | def preview(id, options = {}) 91 | name = "#{Time.now.gmtime.to_i}.jpg" 92 | res = self.get "/translate/job/#{id}/preview", :query => options 93 | check_for_errors(res) 94 | fn = if defined?(Rails) 95 | Rails.root.join('public', 'images', 'mygengo', name) 96 | else 97 | Tempfile.new(name) 98 | end 99 | if !File.exists?(fn) 100 | tempfile = File.new(fn, "w+") 101 | tempfile << res 102 | tempfile.close 103 | "mygengo/#{name}" 104 | else 105 | nil 106 | end 107 | end 108 | 109 | # 110 | # translate/job/{id}/comment (POST) 111 | # 112 | # Submits a new comment to the job's comment thread. 113 | # 114 | def create_comment(job_id, comment) 115 | if comment.nil? || comment.empty? 116 | raise Exception, '"options" missing required parameters' 117 | end 118 | res = self.post "/translate/job/#{job_id}/comment", :body => comment 119 | check_for_errors(res) 120 | res['response'] 121 | end 122 | 123 | # 124 | # translate/job/{id}/comments (GET) 125 | # 126 | # Retrieves the comment thread for a job 127 | # 128 | def comments(id, options = {}) 129 | res = self.get "/translate/job/#{id}/comments", :query => options 130 | check_for_errors(res) 131 | res['response']['thread'] 132 | end 133 | 134 | # 135 | # translate/job/{id}/feedback (GET) 136 | # 137 | # Retrieves the feedback 138 | # 139 | def feedback(id, options = {}) 140 | res = self.get "/translate/job/#{id}/feedback", :query => options 141 | check_for_errors(res) 142 | res['response']['feedback'] 143 | end 144 | 145 | # 146 | # translate/job/{id}/revisions (GET) 147 | # 148 | # Gets list of revision resources for a job. 149 | # 150 | def revisions(id, options = {}) 151 | res = self.get "/translate/job/#{id}/revisions", :query => options 152 | check_for_errors(res) 153 | res['response']['revisions'] 154 | end 155 | 156 | # 157 | # translate/job/{job_id}/revision/{id} (GET) 158 | # 159 | # Gets specific revision for a job. 160 | # 161 | def revision(job_id, id, options = {}) 162 | res = self.get "/translate/job/#{job_id}/revision/#{id}", :query => options 163 | check_for_errors(res) 164 | res['response']['revision'] 165 | end 166 | 167 | end 168 | end 169 | end -------------------------------------------------------------------------------- /generators/templates/public/stylesheets/mygengo/base.css: -------------------------------------------------------------------------------- 1 | * {margin:0;padding:0} 2 | .clear { clear: both; height: 0; } 3 | 4 | .wat-cf:after { 5 | content: "."; 6 | display: block; 7 | height: 0; 8 | clear: both; 9 | visibility: hidden; 10 | } 11 | 12 | .wat-cf {display: inline-block;} 13 | 14 | /* Hides from IE-mac \*/ 15 | * html .wat-cf {height: 1%;} 16 | .wat-cf {display: block;} 17 | /* End hide from IE-mac */ 18 | 19 | h1 { margin: 15px 0; font-size: 22px; font-weight: normal; } 20 | h2 { font-size: 22px; margin: 15px 0; font-weight: normal;} 21 | h3 { font-size: 18px; margin: 10px 0; font-weight: normal;} 22 | h4 { font-size: 16px; margin: 10px 0; font-weight: normal;} 23 | hr {height: 1px; border: 0; } 24 | p { margin: 15px 0;} 25 | a img { border: none; } 26 | 27 | body { 28 | font-size: 12px; 29 | font-family: sans-serif; 30 | } 31 | 32 | #container { 33 | min-width: 960px; 34 | } 35 | 36 | #header, #wrapper { 37 | padding: 0 20px; 38 | } 39 | 40 | #header { 41 | position: relative; 42 | padding-top: 1px; 43 | } 44 | 45 | #header h1 { 46 | margin: 0; 47 | padding: 10px 0; 48 | font-size: 26px; 49 | } 50 | 51 | #header h1 a:link, #header h1 a:active, #header h1 a:hover, #header h1 a:visited { 52 | text-decoration: none; 53 | } 54 | 55 | #main { 56 | width: 70%; 57 | float: left; 58 | } 59 | 60 | .actions-bar { 61 | padding: 10px 1px; 62 | } 63 | 64 | .actions-bar .actions { 65 | float: left; 66 | } 67 | 68 | 69 | .actions-bar .pagination { 70 | float: right; 71 | padding: 1px 0; 72 | } 73 | 74 | #sidebar { 75 | width: 25%; 76 | float: right; 77 | } 78 | 79 | #sidebar h3 { 80 | padding: 10px 15px; 81 | margin: 0; 82 | font-size: 13px; 83 | } 84 | 85 | #sidebar .block { 86 | margin-bottom: 20px; 87 | padding-bottom: 10px; 88 | } 89 | 90 | #sidebar .block .content { 91 | padding: 0 15px; 92 | } 93 | 94 | #sidebar ul.navigation li a:link, #sidebar ul.navigation li a:visited { 95 | display: block; 96 | padding: 10px 15px; 97 | } 98 | 99 | #sidebar .block .sidebar-block, #sidebar .notice { 100 | padding:10px; 101 | } 102 | 103 | #wrapper { 104 | padding-top: 20px; 105 | } 106 | 107 | #main .block { 108 | margin-bottom: 20px; 109 | padding-top: 1px; 110 | } 111 | 112 | #main .block .content .inner { 113 | padding: 0 15px 15px; 114 | } 115 | 116 | #main .main p.first { 117 | margin-top: 0; 118 | } 119 | 120 | #user-navigation { 121 | position: absolute; 122 | top: 0px; 123 | right: 20px; 124 | } 125 | 126 | #main-navigation { 127 | width: 100%; 128 | } 129 | 130 | #user-navigation ul, #main-navigation ul, .secondary-navigation ul, #sidebar ul.navigation { 131 | margin: 0; 132 | padding: 0; 133 | list-style-type: none; 134 | } 135 | 136 | #user-navigation ul li, #main-navigation ul li, .secondary-navigation ul li { 137 | float: left; 138 | } 139 | 140 | #main-navigation ul li { 141 | margin-right: 5px; 142 | } 143 | 144 | #user-navigation ul li { 145 | padding: 5px 10px; 146 | } 147 | 148 | #main-navigation ul li a:link, #main-navigation ul li a:visited, #main-navigation ul li a:hover, #main-navigation ul li a:active, 149 | .secondary-navigation ul li a:link, .secondary-navigation ul li a:visited, .secondary-navigation ul li a:hover, .secondary-navigation ul li a:active, 150 | #user-navigation ul li a:link, #user-navigation ul li a:visited, #user-navigation ul li a:hover, #user-navigation ul li a:active { 151 | text-decoration: none; 152 | } 153 | 154 | #main-navigation ul li a { 155 | font-size: 14px; 156 | line-height: 14px; 157 | display: block; 158 | padding: 8px 15px; 159 | } 160 | 161 | .secondary-navigation { 162 | font-size: 13px; 163 | border-bottom-width: 10px; 164 | border-bottom-style: solid; 165 | } 166 | 167 | .secondary-navigation ul li a { 168 | display: block; 169 | padding: 10px 15px; 170 | } 171 | 172 | #footer { 173 | padding-bottom: 20px; 174 | } 175 | 176 | /* pagination */ 177 | 178 | .pagination a, .pagination span, .pagination em { 179 | padding: 2px 5px; 180 | margin-right: 5px; 181 | display: block; 182 | float: left; 183 | border-style: solid; 184 | border-width: 1px; 185 | } 186 | 187 | .pagination em { 188 | font-weight: bold; 189 | } 190 | 191 | .pagination a { 192 | text-decoration: none; 193 | } 194 | 195 | /* tables */ 196 | .table { 197 | width: 100%; 198 | border-collapse: collapse; 199 | margin-bottom: 15px; 200 | } 201 | 202 | .table th { 203 | padding: 10px; 204 | font-weight: bold; 205 | text-align: left; 206 | } 207 | 208 | .table th.first { 209 | width: 30px; 210 | } 211 | 212 | .table th.last { 213 | width: 200px; 214 | } 215 | 216 | .table .checkbox { 217 | margin-left: 10px; 218 | } 219 | 220 | .table td { 221 | padding: 10px; 222 | } 223 | 224 | .table td.last { 225 | text-align: right; 226 | } 227 | 228 | /* forms */ 229 | 230 | input.checkbox { 231 | margin: 0; 232 | padding: 0; 233 | } 234 | 235 | .form .group { 236 | margin-bottom: 15px; 237 | } 238 | 239 | .form div.left { 240 | width: 20%; 241 | float: left; 242 | } 243 | 244 | .form div.right { 245 | width: 75%; 246 | float: right; 247 | } 248 | 249 | .form .columns .column { 250 | width: 48%; 251 | } 252 | 253 | .form .columns .left { 254 | float: left; 255 | } 256 | 257 | .form .columns .right { 258 | float: right; 259 | } 260 | 261 | .form label.label, .form input.text_field, .form textarea.text_area { 262 | font-size: 1.2em; 263 | padding: 1px 0; 264 | margin: 0; 265 | } 266 | 267 | .form label.right { 268 | text-align: right; 269 | } 270 | 271 | .form input.checkbox, .form input.radio { 272 | margin-right: 5px; 273 | } 274 | 275 | .form label.checkbox, .form label.radio { 276 | line-height: 1.5em; 277 | } 278 | 279 | .form label.label { 280 | display: block; 281 | padding-bottom: 2px; 282 | font-weight: bold; 283 | } 284 | 285 | .form div.fieldWithErrors label.label { 286 | display: inline; 287 | } 288 | 289 | .form .fieldWithErrors .error { 290 | color: red; 291 | } 292 | 293 | .form input.text_field, .form textarea.text_area { 294 | width: 100%; 295 | border-width: 1px; 296 | border-style: solid; 297 | } 298 | 299 | /* lists */ 300 | 301 | ul.list { 302 | margin: 0; 303 | padding: 0; 304 | list-style-type: none; 305 | } 306 | 307 | ul.list li { 308 | clear: left; 309 | padding-bottom: 5px; 310 | } 311 | 312 | ul.list li .left { 313 | float: left; 314 | } 315 | 316 | ul.list li .left .avatar { 317 | width: 50px; 318 | height: 50px; 319 | } 320 | 321 | ul.list li .item { 322 | margin-left: 80px; 323 | } 324 | 325 | ul.list li .item .avatar { 326 | float: left; 327 | margin: 0 5px 5px 0; 328 | width: 30px; 329 | height: 30px; 330 | } 331 | 332 | /* box */ 333 | 334 | #box { 335 | width: 500px; 336 | margin: 50px auto; 337 | } 338 | 339 | #box .block { 340 | margin-bottom: 20px; 341 | } 342 | 343 | #box .block h2 { 344 | padding: 10px 15px; 345 | margin: 0; 346 | } 347 | 348 | #box .block .content { 349 | padding: 10px 20px; 350 | } 351 | 352 | /* Inspired by http://particletree.com/features/rediscovering-the-button-element */ 353 | 354 | a.button:link, a.button:visited, a.button:hover, a.button:active, button.button { 355 | color: #222; 356 | display:block; 357 | float:left; 358 | margin:0 7px 0 0; 359 | background-color: #eee; 360 | border:1px solid #bfbfbf; 361 | font-size: 1em; 362 | line-height: 1.3em; 363 | font-weight:bold; 364 | cursor:pointer; 365 | padding:5px 10px 6px 7px; 366 | text-decoration: none; 367 | } 368 | 369 | button.button { 370 | width:auto; 371 | overflow:visible; 372 | padding:4px 10px 3px 7px; /* IE6 */ 373 | } 374 | button.button[type] { 375 | padding:5px 10px 5px 7px; /* Firefox */ 376 | line-height:17px; /* Safari */ 377 | } 378 | 379 | *:first-child+html button.button[type] { 380 | padding:4px 10px 3px 7px; /* IE7 */ 381 | } 382 | 383 | button.button img, a.button img { 384 | margin:0 3px -3px 0 !important; 385 | padding:0; 386 | border:none; 387 | width:16px; 388 | height:16px; 389 | } 390 | 391 | button.button:hover, a.button:hover { 392 | background-color:#dedede; 393 | } 394 | 395 | button.button:active, a.button:active { 396 | background-color:#e5e5e5; 397 | } -------------------------------------------------------------------------------- /lib/generators/mugen/templates/public/stylesheets/mygengo/base.css: -------------------------------------------------------------------------------- 1 | * {margin:0;padding:0} 2 | .clear { clear: both; height: 0; } 3 | 4 | .wat-cf:after { 5 | content: "."; 6 | display: block; 7 | height: 0; 8 | clear: both; 9 | visibility: hidden; 10 | } 11 | 12 | .wat-cf {display: inline-block;} 13 | 14 | /* Hides from IE-mac \*/ 15 | * html .wat-cf {height: 1%;} 16 | .wat-cf {display: block;} 17 | /* End hide from IE-mac */ 18 | 19 | h1 { margin: 15px 0; font-size: 22px; font-weight: normal; } 20 | h2 { font-size: 22px; margin: 15px 0; font-weight: normal;} 21 | h3 { font-size: 18px; margin: 10px 0; font-weight: normal;} 22 | h4 { font-size: 16px; margin: 10px 0; font-weight: normal;} 23 | hr {height: 1px; border: 0; } 24 | p { margin: 15px 0;} 25 | a img { border: none; } 26 | 27 | body { 28 | font-size: 12px; 29 | font-family: sans-serif; 30 | } 31 | 32 | #container { 33 | min-width: 960px; 34 | } 35 | 36 | #header, #wrapper { 37 | padding: 0 20px; 38 | } 39 | 40 | #header { 41 | position: relative; 42 | padding-top: 1px; 43 | } 44 | 45 | #header h1 { 46 | margin: 0; 47 | padding: 10px 0; 48 | font-size: 26px; 49 | } 50 | 51 | #header h1 a:link, #header h1 a:active, #header h1 a:hover, #header h1 a:visited { 52 | text-decoration: none; 53 | } 54 | 55 | #main { 56 | width: 70%; 57 | float: left; 58 | } 59 | 60 | .actions-bar { 61 | padding: 10px 1px; 62 | } 63 | 64 | .actions-bar .actions { 65 | float: left; 66 | } 67 | 68 | 69 | .actions-bar .pagination { 70 | float: right; 71 | padding: 1px 0; 72 | } 73 | 74 | #sidebar { 75 | width: 25%; 76 | float: right; 77 | } 78 | 79 | #sidebar h3 { 80 | padding: 10px 15px; 81 | margin: 0; 82 | font-size: 13px; 83 | } 84 | 85 | #sidebar .block { 86 | margin-bottom: 20px; 87 | padding-bottom: 10px; 88 | } 89 | 90 | #sidebar .block .content { 91 | padding: 0 15px; 92 | } 93 | 94 | #sidebar ul.navigation li a:link, #sidebar ul.navigation li a:visited { 95 | display: block; 96 | padding: 10px 15px; 97 | } 98 | 99 | #sidebar .block .sidebar-block, #sidebar .notice { 100 | padding:10px; 101 | } 102 | 103 | #wrapper { 104 | padding-top: 20px; 105 | } 106 | 107 | #main .block { 108 | margin-bottom: 20px; 109 | padding-top: 1px; 110 | } 111 | 112 | #main .block .content .inner { 113 | padding: 0 15px 15px; 114 | } 115 | 116 | #main .main p.first { 117 | margin-top: 0; 118 | } 119 | 120 | #user-navigation { 121 | position: absolute; 122 | top: 0px; 123 | right: 20px; 124 | } 125 | 126 | #main-navigation { 127 | width: 100%; 128 | } 129 | 130 | #user-navigation ul, #main-navigation ul, .secondary-navigation ul, #sidebar ul.navigation { 131 | margin: 0; 132 | padding: 0; 133 | list-style-type: none; 134 | } 135 | 136 | #user-navigation ul li, #main-navigation ul li, .secondary-navigation ul li { 137 | float: left; 138 | } 139 | 140 | #main-navigation ul li { 141 | margin-right: 5px; 142 | } 143 | 144 | #user-navigation ul li { 145 | padding: 5px 10px; 146 | } 147 | 148 | #main-navigation ul li a:link, #main-navigation ul li a:visited, #main-navigation ul li a:hover, #main-navigation ul li a:active, 149 | .secondary-navigation ul li a:link, .secondary-navigation ul li a:visited, .secondary-navigation ul li a:hover, .secondary-navigation ul li a:active, 150 | #user-navigation ul li a:link, #user-navigation ul li a:visited, #user-navigation ul li a:hover, #user-navigation ul li a:active { 151 | text-decoration: none; 152 | } 153 | 154 | #main-navigation ul li a { 155 | font-size: 14px; 156 | line-height: 14px; 157 | display: block; 158 | padding: 8px 15px; 159 | } 160 | 161 | .secondary-navigation { 162 | font-size: 13px; 163 | border-bottom-width: 10px; 164 | border-bottom-style: solid; 165 | } 166 | 167 | .secondary-navigation ul li a { 168 | display: block; 169 | padding: 10px 15px; 170 | } 171 | 172 | #footer { 173 | padding-bottom: 20px; 174 | } 175 | 176 | /* pagination */ 177 | 178 | .pagination a, .pagination span, .pagination em { 179 | padding: 2px 5px; 180 | margin-right: 5px; 181 | display: block; 182 | float: left; 183 | border-style: solid; 184 | border-width: 1px; 185 | } 186 | 187 | .pagination em { 188 | font-weight: bold; 189 | } 190 | 191 | .pagination a { 192 | text-decoration: none; 193 | } 194 | 195 | /* tables */ 196 | .table { 197 | width: 100%; 198 | border-collapse: collapse; 199 | margin-bottom: 15px; 200 | } 201 | 202 | .table th { 203 | padding: 10px; 204 | font-weight: bold; 205 | text-align: left; 206 | } 207 | 208 | .table th.first { 209 | width: 30px; 210 | } 211 | 212 | .table th.last { 213 | width: 200px; 214 | } 215 | 216 | .table .checkbox { 217 | margin-left: 10px; 218 | } 219 | 220 | .table td { 221 | padding: 10px; 222 | } 223 | 224 | .table td.last { 225 | text-align: right; 226 | } 227 | 228 | /* forms */ 229 | 230 | input.checkbox { 231 | margin: 0; 232 | padding: 0; 233 | } 234 | 235 | .form .group { 236 | margin-bottom: 15px; 237 | } 238 | 239 | .form div.left { 240 | width: 20%; 241 | float: left; 242 | } 243 | 244 | .form div.right { 245 | width: 75%; 246 | float: right; 247 | } 248 | 249 | .form .columns .column { 250 | width: 48%; 251 | } 252 | 253 | .form .columns .left { 254 | float: left; 255 | } 256 | 257 | .form .columns .right { 258 | float: right; 259 | } 260 | 261 | .form label.label, .form input.text_field, .form textarea.text_area { 262 | font-size: 1.2em; 263 | padding: 1px 0; 264 | margin: 0; 265 | } 266 | 267 | .form label.right { 268 | text-align: right; 269 | } 270 | 271 | .form input.checkbox, .form input.radio { 272 | margin-right: 5px; 273 | } 274 | 275 | .form label.checkbox, .form label.radio { 276 | line-height: 1.5em; 277 | } 278 | 279 | .form label.label { 280 | display: block; 281 | padding-bottom: 2px; 282 | font-weight: bold; 283 | } 284 | 285 | .form div.fieldWithErrors label.label { 286 | display: inline; 287 | } 288 | 289 | .form .fieldWithErrors .error { 290 | color: red; 291 | } 292 | 293 | .form input.text_field, .form textarea.text_area { 294 | width: 100%; 295 | border-width: 1px; 296 | border-style: solid; 297 | } 298 | 299 | /* lists */ 300 | 301 | ul.list { 302 | margin: 0; 303 | padding: 0; 304 | list-style-type: none; 305 | } 306 | 307 | ul.list li { 308 | clear: left; 309 | padding-bottom: 5px; 310 | } 311 | 312 | ul.list li .left { 313 | float: left; 314 | } 315 | 316 | ul.list li .left .avatar { 317 | width: 50px; 318 | height: 50px; 319 | } 320 | 321 | ul.list li .item { 322 | margin-left: 80px; 323 | } 324 | 325 | ul.list li .item .avatar { 326 | float: left; 327 | margin: 0 5px 5px 0; 328 | width: 30px; 329 | height: 30px; 330 | } 331 | 332 | /* box */ 333 | 334 | #box { 335 | width: 500px; 336 | margin: 50px auto; 337 | } 338 | 339 | #box .block { 340 | margin-bottom: 20px; 341 | } 342 | 343 | #box .block h2 { 344 | padding: 10px 15px; 345 | margin: 0; 346 | } 347 | 348 | #box .block .content { 349 | padding: 10px 20px; 350 | } 351 | 352 | /* Inspired by http://particletree.com/features/rediscovering-the-button-element */ 353 | 354 | a.button:link, a.button:visited, a.button:hover, a.button:active, button.button { 355 | color: #222; 356 | display:block; 357 | float:left; 358 | margin:0 7px 0 0; 359 | background-color: #eee; 360 | border:1px solid #bfbfbf; 361 | font-size: 1em; 362 | line-height: 1.3em; 363 | font-weight:bold; 364 | cursor:pointer; 365 | padding:5px 10px 6px 7px; 366 | text-decoration: none; 367 | } 368 | 369 | button.button { 370 | width:auto; 371 | overflow:visible; 372 | padding:4px 10px 3px 7px; /* IE6 */ 373 | } 374 | button.button[type] { 375 | padding:5px 10px 5px 7px; /* Firefox */ 376 | line-height:17px; /* Safari */ 377 | } 378 | 379 | *:first-child+html button.button[type] { 380 | padding:4px 10px 3px 7px; /* IE7 */ 381 | } 382 | 383 | button.button img, a.button img { 384 | margin:0 3px -3px 0 !important; 385 | padding:0; 386 | border:none; 387 | width:16px; 388 | height:16px; 389 | } 390 | 391 | button.button:hover, a.button:hover { 392 | background-color:#dedede; 393 | } 394 | 395 | button.button:active, a.button:active { 396 | background-color:#e5e5e5; 397 | } -------------------------------------------------------------------------------- /generators/templates/public/stylesheets/mygengo/style.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Drastic Dark 4 | by Juan Maria Martinez Arce 5 | juan[at]insignia4u.com 6 | 7 | light grey: #cfcfcf 8 | medium grey: #36393d 9 | dark grey: #1a1a1a 10 | interactive action yellow #ffff88 11 | red #cc0000 12 | light blue #E6EEFC 13 | dark blue #0B43A8 14 | 15 | */ 16 | 17 | .small { 18 | font-size: 11px; 19 | font-style: normal; 20 | font-weight: normal; 21 | text-transform: normal; 22 | letter-spacing: normal; 23 | line-height: 1.4em; 24 | } 25 | 26 | .gray { 27 | color:#999999; 28 | font-family: Georgia, serif; 29 | font-size: 13px; 30 | font-style: italic; 31 | font-weight: normal; 32 | text-transform: normal; 33 | letter-spacing: normal; 34 | line-height: 1.6em; 35 | } 36 | 37 | .hightlight { 38 | background-color: #ffff88; 39 | font-weight: bold; 40 | color: #36393d; 41 | } 42 | 43 | a:link, a:visited, a:hover, a:active, h1, h2, h3 { color: #36393d; } 44 | a { -moz-outline: none; } 45 | 46 | body { 47 | color: #222; 48 | background: #cfcfcf; 49 | font-family: helvetica, arial, sans-serif; 50 | } 51 | 52 | hr { 53 | background: #f0f0ee; 54 | color: #f0f0ee; 55 | } 56 | 57 | #header { 58 | background: #36393d; 59 | } 60 | 61 | #header h1 { 62 | padding: 15px 0; 63 | font-size: 28px; 64 | font-style: normal; 65 | font-weight: bold; 66 | text-transform: normal; 67 | letter-spacing: -1px; 68 | line-height: 1.2em; 69 | } 70 | 71 | #header h1 a:link, #header h1 a:active, #header h1 a:hover, #header h1 a:visited { 72 | color: #FFF; 73 | } 74 | 75 | #user-navigation { 76 | top: auto; 77 | bottom: 5px; 78 | right: 25px; 79 | } 80 | 81 | #user-navigation a.logout { 82 | background: #cc0000; 83 | padding: 1px 4px; 84 | -moz-border-radius: 4px; 85 | -webkit-border-radius: 3px; 86 | } 87 | 88 | #main .block .content { 89 | background: #FFF; 90 | padding-top: 1px; 91 | } 92 | 93 | #main .block .content h2 { 94 | margin-left: 15px; 95 | font-size: 22px; 96 | font-style: normal; 97 | font-weight: bold; 98 | text-transform: normal; 99 | letter-spacing: -1px; 100 | line-height: 1.2em; 101 | } 102 | 103 | #main .block .content p { 104 | font-size: 13px; 105 | font-style: normal; 106 | font-weight: normal; 107 | text-transform: normal; 108 | letter-spacing: normal; 109 | line-height: 1.45em; 110 | } 111 | 112 | #sidebar .block { 113 | background: #FFF; 114 | } 115 | 116 | #sidebar .block h4 { 117 | font-weight: bold; 118 | } 119 | 120 | #sidebar .notice { 121 | background: #E6EEFC; 122 | } 123 | 124 | #sidebar .notice h4 { 125 | color: #0B43A8; 126 | } 127 | 128 | #sidebar h3 { 129 | background: #36393d; 130 | color: #FFF; 131 | border-bottom: 5px solid #1a1a1a; 132 | } 133 | 134 | #main-navigation ul li { 135 | padding-left: 15px; 136 | } 137 | 138 | #main-navigation ul li a { 139 | padding: 8px 0; 140 | } 141 | 142 | #main-navigation ul li.active { 143 | padding: 0; 144 | margin-left: 15px; 145 | } 146 | 147 | #main-navigation ul li.active { 148 | margin-left: 15px; 149 | } 150 | 151 | #main-navigation ul li.active a { 152 | padding: 8px 15px; 153 | } 154 | 155 | #sidebar ul li a:link, #sidebar ul li a:visited { 156 | background: #FFF; 157 | border-bottom: 1px solid #F0F0EE; 158 | text-decoration: none; 159 | } 160 | 161 | #sidebar ul li a:hover, #sidebar ul li a:active { 162 | background: #666666; 163 | color: #ffffff;; 164 | } 165 | 166 | #main-navigation { 167 | background: #1a1a1a; 168 | } 169 | 170 | #main-navigation ul li { 171 | background: #1a1a1a; 172 | margin-right: 0; 173 | } 174 | 175 | #main-navigation ul li.active { 176 | background: #f0f0ee; 177 | } 178 | 179 | #main-navigation ul li a:link, #main-navigation ul li a:visited, #main-navigation ul li a:hover, #main-navigation ul li a:active, 180 | .secondary-navigation ul li a:link, .secondary-navigation ul li a:visited, .secondary-navigation ul li a:hover, .secondary-navigation ul li a:active, 181 | #user-navigation ul li a:link, #user-navigation ul li a:visited, #user-navigation ul li a:hover, #user-navigation ul li a:active { 182 | text-decoration: none; 183 | color: #FFF; 184 | } 185 | 186 | .secondary-navigation li a:hover { 187 | background: #666666; 188 | } 189 | 190 | #main-navigation ul li.active a:link, #main-navigation ul li.active a:visited, #main-navigation ul li.active a:hover, #main-navigation ul li.active a:active { 191 | color: #1a1a1a; 192 | } 193 | 194 | .secondary-navigation { 195 | background: #36393d; 196 | border-bottom-color: #1a1a1a; 197 | } 198 | 199 | .secondary-navigation ul li.active, .secondary-navigation ul li.active a:hover { 200 | background-color: #1a1a1a; 201 | } 202 | 203 | #footer .block { 204 | color: #FFF; 205 | background: #1a1a1a; 206 | } 207 | 208 | #footer .block p { 209 | margin: 0; 210 | padding: 10px; 211 | } 212 | 213 | /* pagination */ 214 | 215 | .pagination a, .pagination span { 216 | background: #cfcfcf; 217 | -moz-border-radius: 3px; 218 | border: 1px solid #c1c1c1; 219 | } 220 | 221 | .pagination em { 222 | background: #36393d; 223 | color: #FFF; 224 | border: 1px solid #36393d; 225 | } 226 | 227 | .pagination a { 228 | color: #1a1a1a; 229 | } 230 | 231 | .pagination a:hover { 232 | border: 1px solid #666; 233 | } 234 | 235 | /* tables */ 236 | 237 | .table th { 238 | background: #36393d; 239 | color: #FFF; 240 | } 241 | 242 | .table td { 243 | border-bottom:1px solid #F0F0EE; 244 | } 245 | 246 | .table tr.even { 247 | background: #ebebeb; 248 | } 249 | 250 | /* forms */ 251 | 252 | .form label.label { 253 | color: #666666; 254 | } 255 | 256 | .form input.text_field, .form textarea.text_area { 257 | width: 100%; 258 | border: 1px solid #cfcfcf; 259 | } 260 | 261 | .form input.button { 262 | background: #cfcfcf; 263 | -moz-border-radius: 5px; 264 | border: 1px solid #c1c1c1; 265 | padding: 2px 5px; 266 | cursor: pointer; 267 | color: #36393d; 268 | font-weight: bold; 269 | font-size: 11px; 270 | } 271 | 272 | .form input.button:hover { 273 | border: 1px solid #666; 274 | } 275 | 276 | .form .description { 277 | font-style: italic; 278 | color: #8C8C8C; 279 | font-size: .9em; 280 | } 281 | 282 | .form .navform a { 283 | color: #cc0000; 284 | } 285 | 286 | /* flash-messages */ 287 | .flash .message { 288 | -moz-border-radius: 3px; 289 | -webkit-border-radius: 3px; 290 | text-align:center; 291 | margin: 0 auto 15px; 292 | 293 | } 294 | 295 | .flash .message p { 296 | margin:8px; 297 | } 298 | .flash .error { 299 | border: 1px solid #fbb; 300 | background-color: #fdd; 301 | } 302 | .flash .warning { 303 | border: 1px solid #fffaaa; 304 | background-color: #ffffcc; 305 | } 306 | .flash .notice { 307 | border: 1px solid #1FDF00; 308 | background-color: #BBFFB6; 309 | } 310 | 311 | /* lists */ 312 | 313 | ul.list li { 314 | border-bottom-color: #F0F0EE; 315 | border-bottom-width: 1px; 316 | border-bottom-style: solid; 317 | } 318 | 319 | ul.list li .item .avatar { 320 | border-color: #F0F0EE; 321 | border-width: 1px; 322 | border-style: solid; 323 | padding: 2px; 324 | } 325 | 326 | /* box */ 327 | 328 | #box .block { 329 | background: #FFF; 330 | } 331 | 332 | #box .block h2 { 333 | background: #36393d; 334 | color: #FFF; 335 | } 336 | 337 | 338 | /* rounded borders */ 339 | 340 | #main, #main-navigation, #main-navigation li, .secondary-navigation, #main .block, #sidebar .block, #sidebar h3, ul.list li, 341 | #footer .block, .form input.button, #box .block, #box .block h2 { 342 | -moz-border-radius-topleft: 4px; 343 | -webkit-border-top-left-radius: 4px; 344 | -moz-border-radius-topright: 4px; 345 | -webkit-border-top-right-radius: 4px; 346 | } 347 | 348 | .secondary-navigation li.first a, .secondary-navigation ul li.first, .table th.first, .table th.first { 349 | -moz-border-radius-topleft: 4px; 350 | -webkit-border-top-left-radius: 4px; 351 | } 352 | 353 | .table th.last { 354 | -moz-border-radius-topright: 4px; 355 | -webkit-border-top-right-radius: 4px; 356 | } 357 | 358 | .secondary-navigation ul li.first { 359 | -moz-border-radius-topleft: 4px; 360 | -webkit-border-top-left-radius: 4px; 361 | } 362 | 363 | #sidebar, #sidebar .block, #main .block, #sidebar ul.navigation, ul.list li, #footer .block, .form input.button, #box .block { 364 | -moz-border-radius-bottomleft: 4px; 365 | -webkit-border-bottom-left-radius: 4px; 366 | -moz-border-radius-bottomright: 4px; 367 | -webkit-border-bottom-right-radius: 4px; 368 | } 369 | 370 | .secondary-navigation { 371 | border-bottom-width: 5px; 372 | } 373 | 374 | -------------------------------------------------------------------------------- /lib/generators/mugen/templates/public/stylesheets/mygengo/style.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Drastic Dark 4 | by Juan Maria Martinez Arce 5 | juan[at]insignia4u.com 6 | 7 | light grey: #cfcfcf 8 | medium grey: #36393d 9 | dark grey: #1a1a1a 10 | interactive action yellow #ffff88 11 | red #cc0000 12 | light blue #E6EEFC 13 | dark blue #0B43A8 14 | 15 | */ 16 | 17 | .small { 18 | font-size: 11px; 19 | font-style: normal; 20 | font-weight: normal; 21 | text-transform: normal; 22 | letter-spacing: normal; 23 | line-height: 1.4em; 24 | } 25 | 26 | .gray { 27 | color:#999999; 28 | font-family: Georgia, serif; 29 | font-size: 13px; 30 | font-style: italic; 31 | font-weight: normal; 32 | text-transform: normal; 33 | letter-spacing: normal; 34 | line-height: 1.6em; 35 | } 36 | 37 | .hightlight { 38 | background-color: #ffff88; 39 | font-weight: bold; 40 | color: #36393d; 41 | } 42 | 43 | a:link, a:visited, a:hover, a:active, h1, h2, h3 { color: #36393d; } 44 | a { -moz-outline: none; } 45 | 46 | body { 47 | color: #222; 48 | background: #cfcfcf; 49 | font-family: helvetica, arial, sans-serif; 50 | } 51 | 52 | hr { 53 | background: #f0f0ee; 54 | color: #f0f0ee; 55 | } 56 | 57 | #header { 58 | background: #36393d; 59 | } 60 | 61 | #header h1 { 62 | padding: 15px 0; 63 | font-size: 28px; 64 | font-style: normal; 65 | font-weight: bold; 66 | text-transform: normal; 67 | letter-spacing: -1px; 68 | line-height: 1.2em; 69 | } 70 | 71 | #header h1 a:link, #header h1 a:active, #header h1 a:hover, #header h1 a:visited { 72 | color: #FFF; 73 | } 74 | 75 | #user-navigation { 76 | top: auto; 77 | bottom: 5px; 78 | right: 25px; 79 | } 80 | 81 | #user-navigation a.logout { 82 | background: #cc0000; 83 | padding: 1px 4px; 84 | -moz-border-radius: 4px; 85 | -webkit-border-radius: 3px; 86 | } 87 | 88 | #main .block .content { 89 | background: #FFF; 90 | padding-top: 1px; 91 | } 92 | 93 | #main .block .content h2 { 94 | margin-left: 15px; 95 | font-size: 22px; 96 | font-style: normal; 97 | font-weight: bold; 98 | text-transform: normal; 99 | letter-spacing: -1px; 100 | line-height: 1.2em; 101 | } 102 | 103 | #main .block .content p { 104 | font-size: 13px; 105 | font-style: normal; 106 | font-weight: normal; 107 | text-transform: normal; 108 | letter-spacing: normal; 109 | line-height: 1.45em; 110 | } 111 | 112 | #sidebar .block { 113 | background: #FFF; 114 | } 115 | 116 | #sidebar .block h4 { 117 | font-weight: bold; 118 | } 119 | 120 | #sidebar .notice { 121 | background: #E6EEFC; 122 | } 123 | 124 | #sidebar .notice h4 { 125 | color: #0B43A8; 126 | } 127 | 128 | #sidebar h3 { 129 | background: #36393d; 130 | color: #FFF; 131 | border-bottom: 5px solid #1a1a1a; 132 | } 133 | 134 | #main-navigation ul li { 135 | padding-left: 15px; 136 | } 137 | 138 | #main-navigation ul li a { 139 | padding: 8px 0; 140 | } 141 | 142 | #main-navigation ul li.active { 143 | padding: 0; 144 | margin-left: 15px; 145 | } 146 | 147 | #main-navigation ul li.active { 148 | margin-left: 15px; 149 | } 150 | 151 | #main-navigation ul li.active a { 152 | padding: 8px 15px; 153 | } 154 | 155 | #sidebar ul li a:link, #sidebar ul li a:visited { 156 | background: #FFF; 157 | border-bottom: 1px solid #F0F0EE; 158 | text-decoration: none; 159 | } 160 | 161 | #sidebar ul li a:hover, #sidebar ul li a:active { 162 | background: #666666; 163 | color: #ffffff;; 164 | } 165 | 166 | #main-navigation { 167 | background: #1a1a1a; 168 | } 169 | 170 | #main-navigation ul li { 171 | background: #1a1a1a; 172 | margin-right: 0; 173 | } 174 | 175 | #main-navigation ul li.active { 176 | background: #f0f0ee; 177 | } 178 | 179 | #main-navigation ul li a:link, #main-navigation ul li a:visited, #main-navigation ul li a:hover, #main-navigation ul li a:active, 180 | .secondary-navigation ul li a:link, .secondary-navigation ul li a:visited, .secondary-navigation ul li a:hover, .secondary-navigation ul li a:active, 181 | #user-navigation ul li a:link, #user-navigation ul li a:visited, #user-navigation ul li a:hover, #user-navigation ul li a:active { 182 | text-decoration: none; 183 | color: #FFF; 184 | } 185 | 186 | .secondary-navigation li a:hover { 187 | background: #666666; 188 | } 189 | 190 | #main-navigation ul li.active a:link, #main-navigation ul li.active a:visited, #main-navigation ul li.active a:hover, #main-navigation ul li.active a:active { 191 | color: #1a1a1a; 192 | } 193 | 194 | .secondary-navigation { 195 | background: #36393d; 196 | border-bottom-color: #1a1a1a; 197 | } 198 | 199 | .secondary-navigation ul li.active, .secondary-navigation ul li.active a:hover { 200 | background-color: #1a1a1a; 201 | } 202 | 203 | #footer .block { 204 | color: #FFF; 205 | background: #1a1a1a; 206 | } 207 | 208 | #footer .block p { 209 | margin: 0; 210 | padding: 10px; 211 | } 212 | 213 | /* pagination */ 214 | 215 | .pagination a, .pagination span { 216 | background: #cfcfcf; 217 | -moz-border-radius: 3px; 218 | border: 1px solid #c1c1c1; 219 | } 220 | 221 | .pagination em { 222 | background: #36393d; 223 | color: #FFF; 224 | border: 1px solid #36393d; 225 | } 226 | 227 | .pagination a { 228 | color: #1a1a1a; 229 | } 230 | 231 | .pagination a:hover { 232 | border: 1px solid #666; 233 | } 234 | 235 | /* tables */ 236 | 237 | .table th { 238 | background: #36393d; 239 | color: #FFF; 240 | } 241 | 242 | .table td { 243 | border-bottom:1px solid #F0F0EE; 244 | } 245 | 246 | .table tr.even { 247 | background: #ebebeb; 248 | } 249 | 250 | /* forms */ 251 | 252 | .form label.label { 253 | color: #666666; 254 | } 255 | 256 | .form input.text_field, .form textarea.text_area { 257 | width: 100%; 258 | border: 1px solid #cfcfcf; 259 | } 260 | 261 | .form input.button { 262 | background: #cfcfcf; 263 | -moz-border-radius: 5px; 264 | border: 1px solid #c1c1c1; 265 | padding: 2px 5px; 266 | cursor: pointer; 267 | color: #36393d; 268 | font-weight: bold; 269 | font-size: 11px; 270 | } 271 | 272 | .form input.button:hover { 273 | border: 1px solid #666; 274 | } 275 | 276 | .form .description { 277 | font-style: italic; 278 | color: #8C8C8C; 279 | font-size: .9em; 280 | } 281 | 282 | .form .navform a { 283 | color: #cc0000; 284 | } 285 | 286 | /* flash-messages */ 287 | .flash .message { 288 | -moz-border-radius: 3px; 289 | -webkit-border-radius: 3px; 290 | text-align:center; 291 | margin: 0 auto 15px; 292 | 293 | } 294 | 295 | .flash .message p { 296 | margin:8px; 297 | } 298 | .flash .error { 299 | border: 1px solid #fbb; 300 | background-color: #fdd; 301 | } 302 | .flash .warning { 303 | border: 1px solid #fffaaa; 304 | background-color: #ffffcc; 305 | } 306 | .flash .notice { 307 | border: 1px solid #1FDF00; 308 | background-color: #BBFFB6; 309 | } 310 | 311 | /* lists */ 312 | 313 | ul.list li { 314 | border-bottom-color: #F0F0EE; 315 | border-bottom-width: 1px; 316 | border-bottom-style: solid; 317 | } 318 | 319 | ul.list li .item .avatar { 320 | border-color: #F0F0EE; 321 | border-width: 1px; 322 | border-style: solid; 323 | padding: 2px; 324 | } 325 | 326 | /* box */ 327 | 328 | #box .block { 329 | background: #FFF; 330 | } 331 | 332 | #box .block h2 { 333 | background: #36393d; 334 | color: #FFF; 335 | } 336 | 337 | 338 | /* rounded borders */ 339 | 340 | #main, #main-navigation, #main-navigation li, .secondary-navigation, #main .block, #sidebar .block, #sidebar h3, ul.list li, 341 | #footer .block, .form input.button, #box .block, #box .block h2 { 342 | -moz-border-radius-topleft: 4px; 343 | -webkit-border-top-left-radius: 4px; 344 | -moz-border-radius-topright: 4px; 345 | -webkit-border-top-right-radius: 4px; 346 | } 347 | 348 | .secondary-navigation li.first a, .secondary-navigation ul li.first, .table th.first, .table th.first { 349 | -moz-border-radius-topleft: 4px; 350 | -webkit-border-top-left-radius: 4px; 351 | } 352 | 353 | .table th.last { 354 | -moz-border-radius-topright: 4px; 355 | -webkit-border-top-right-radius: 4px; 356 | } 357 | 358 | .secondary-navigation ul li.first { 359 | -moz-border-radius-topleft: 4px; 360 | -webkit-border-top-left-radius: 4px; 361 | } 362 | 363 | #sidebar, #sidebar .block, #main .block, #sidebar ul.navigation, ul.list li, #footer .block, .form input.button, #box .block { 364 | -moz-border-radius-bottomleft: 4px; 365 | -webkit-border-bottom-left-radius: 4px; 366 | -moz-border-radius-bottomright: 4px; 367 | -webkit-border-bottom-right-radius: 4px; 368 | } 369 | 370 | .secondary-navigation { 371 | border-bottom-width: 5px; 372 | } 373 | 374 | --------------------------------------------------------------------------------