From 11d5c2683fe0f296280fa4b717db92b1d358d704 Mon Sep 17 00:00:00 2001 From: re4k Date: Sat, 9 Mar 2013 19:48:53 +0900 Subject: [PATCH] * Fix #1 * Increase worker --- .gitignore | 36 +-- Gemfile | 26 +- Gemfile.lock | 175 +++++++++++- README.md | 37 +++ web/Rakefile => Rakefile | 0 app/assets/images/bird_gray_16.png | Bin 0 -> 1106 bytes {web/app => app}/assets/images/rails.png | Bin .../assets/javascripts/application.js | 0 app/assets/javascripts/errors.js.coffee | 3 + .../assets/javascripts/i.js.coffee | 0 .../assets/javascripts/main.js.coffee | 0 .../assets/javascripts/sessions.js.coffee | 0 .../assets/javascripts/users.js.coffee | 0 .../assets/stylesheets/_tweets.css.sass | 10 +- .../assets/stylesheets/application.css.sass | 5 +- app/assets/stylesheets/errors.css.scss | 3 + .../controllers/application_controller.rb | 10 +- app/controllers/errors_controller.rb | 7 + app/controllers/i_controller.rb | 8 + .../controllers/main_controller.rb | 0 .../controllers/sessions_controller.rb | 0 .../controllers/users_controller.rb | 32 +-- .../app => app}/helpers/application_helper.rb | 12 +- app/helpers/errors_helper.rb | 2 + {web/app => app}/helpers/i_helper.rb | 0 {web/app => app}/helpers/main_helper.rb | 0 {web/app => app}/helpers/sessions_helper.rb | 0 {web/app => app}/helpers/users_helper.rb | 0 {web/app => app}/models/account.rb | 0 {web/app => app}/models/favorite.rb | 0 {web/app => app}/models/retweet.rb | 0 {web/app => app}/models/tweet.rb | 0 {web/app => app}/models/user.rb | 0 app/views/errors/error_404.html.haml | 1 + app/views/errors/error_500.html.haml | 1 + {web/app => app}/views/i/show.haml | 4 +- .../views/layouts/application.haml | 0 app/views/main/index.haml | 23 ++ {web/app => app}/views/shared/_tweet.haml | 16 +- {web/app => app}/views/shared/_tweets.haml | 4 +- {web/app => app}/views/users/best.haml | 0 {web/app => app}/views/users/info.haml | 0 .../recent.haml => app/views/users/my.haml | 0 .../views/users/recent.haml | 0 app/views/users/timeline.haml | 1 + web/config.ru => config.ru | 0 {web/config => config}/application.rb | 0 {web/config => config}/boot.rb | 0 config/database.yml | 16 ++ {web/config => config}/environment.rb | 0 .../environments/development.rb | 0 .../environments/production.rb | 2 +- {web/config => config}/environments/test.rb | 0 .../initializers/backtrace_silencers.rb | 0 .../initializers/filter_parameter_logging.rb | 0 {web/config => config}/initializers/haml.rb | 0 .../initializers/inflections.rb | 0 .../initializers/mime_types.rb | 7 +- .../initializers/omniauth.rb | 0 .../initializers/rails_config.rb | 0 .../initializers/secret_token.rb | 0 .../initializers/session_store.rb | 0 .../initializers/wrap_parameters.rb | 0 {web/config => config}/locales/en.yml | 0 config/routes.rb | 21 ++ config/settings.yml | 12 + .../settings/development.yml | 0 .../config => config}/settings/production.yml | 0 {web/config => config}/settings/test.yml | 0 .../migrate/20130225123010_create_accounts.rb | 0 .../migrate/20130226145932_create_users.rb | 0 .../migrate/20130226150329_create_tweets.rb | 0 .../20130226150829_create_favorites.rb | 0 .../migrate/20130226151042_create_retweets.rb | 0 {web/db => db}/schema.rb | 0 {web/db => db}/seeds.rb | 0 lib/receiver/logger.rb | 42 +++ {worker => lib}/receiver/worker.rb | 112 ++++---- {web/public => public}/404.xhtml | 0 {web/public => public}/422.xhtml | 0 {web/public => public}/500.xhtml | 0 ...ation-37cb32f627581ac8bac91345987e7f10.css | 20 +- ...on-37cb32f627581ac8bac91345987e7f10.css.gz | Bin 0 -> 725 bytes ...cation-47a9a60feaec5625a9c66b1c985a1179.js | 5 + ...ion-47a9a60feaec5625a9c66b1c985a1179.js.gz | Bin 410 -> 410 bytes ...ay_16-93f51980875017e26744056b62aaac22.png | Bin 0 -> 1106 bytes ...fest-0b26a376c9cfe81af432b634628ee75d.json | 1 + ...rails-bc7d436ef8afbf0f88829742a43ba3a4.png | Bin {web/public => public}/favicon.ico | 0 {web/script => script}/rails | 0 start.rb | 8 - test/controllers/errors_controller_test.rb | 14 + test/helpers/errors_helper_test.rb | 4 + web/Gemfile | 50 ---- web/Gemfile.lock | 182 ------------ web/README.rdoc | 261 ------------------ web/app/controllers/i_controller.rb | 7 - web/app/mailers/.gitkeep | 0 web/app/models/.gitkeep | 0 web/app/views/main/index.haml | 13 - web/app/views/users/my.haml | 2 - web/config/database.yml | 33 --- web/config/routes.rb | 24 -- web/config/settings.yml | 4 - web/lib/assets/.gitkeep | 0 web/lib/tasks/.gitkeep | 0 web/log/.gitkeep | 0 ...on-862b4db892f94edcb21b7275b0a049b0.css.gz | Bin 650 -> 0 bytes ...ation-c11f88ddf5d2294cfc1779fcb0be52cf.css | 84 ------ ...on-c11f88ddf5d2294cfc1779fcb0be52cf.css.gz | Bin 598 -> 0 bytes ...fest-6b01fb44e2a668d3c0196abd4bdfbb15.json | 1 - web/vendor/assets/javascripts/.gitkeep | 0 web/vendor/assets/stylesheets/.gitkeep | 0 web/vendor/plugins/.gitkeep | 0 worker.sh | 5 + worker/receiver.rb | 6 - worker/receiver/logger.rb | 28 -- 117 files changed, 551 insertions(+), 829 deletions(-) mode change 120000 => 100644 Gemfile mode change 120000 => 100644 Gemfile.lock create mode 100644 README.md rename web/Rakefile => Rakefile (100%) create mode 100644 app/assets/images/bird_gray_16.png rename {web/app => app}/assets/images/rails.png (100%) rename {web/app => app}/assets/javascripts/application.js (100%) create mode 100644 app/assets/javascripts/errors.js.coffee rename {web/app => app}/assets/javascripts/i.js.coffee (100%) rename {web/app => app}/assets/javascripts/main.js.coffee (100%) rename {web/app => app}/assets/javascripts/sessions.js.coffee (100%) rename {web/app => app}/assets/javascripts/users.js.coffee (100%) rename {web/app => app}/assets/stylesheets/_tweets.css.sass (89%) rename {web/app => app}/assets/stylesheets/application.css.sass (69%) create mode 100644 app/assets/stylesheets/errors.css.scss rename {web/app => app}/controllers/application_controller.rb (60%) create mode 100644 app/controllers/errors_controller.rb create mode 100644 app/controllers/i_controller.rb rename {web/app => app}/controllers/main_controller.rb (100%) rename {web/app => app}/controllers/sessions_controller.rb (100%) rename {web/app => app}/controllers/users_controller.rb (68%) rename {web/app => app}/helpers/application_helper.rb (56%) create mode 100644 app/helpers/errors_helper.rb rename {web/app => app}/helpers/i_helper.rb (100%) rename {web/app => app}/helpers/main_helper.rb (100%) rename {web/app => app}/helpers/sessions_helper.rb (100%) rename {web/app => app}/helpers/users_helper.rb (100%) rename {web/app => app}/models/account.rb (100%) rename {web/app => app}/models/favorite.rb (100%) rename {web/app => app}/models/retweet.rb (100%) rename {web/app => app}/models/tweet.rb (100%) rename {web/app => app}/models/user.rb (100%) create mode 100644 app/views/errors/error_404.html.haml create mode 100644 app/views/errors/error_500.html.haml rename {web/app => app}/views/i/show.haml (63%) rename {web/app => app}/views/layouts/application.haml (100%) create mode 100644 app/views/main/index.haml rename {web/app => app}/views/shared/_tweet.haml (52%) rename {web/app => app}/views/shared/_tweets.haml (65%) rename {web/app => app}/views/users/best.haml (100%) rename {web/app => app}/views/users/info.haml (100%) rename web/app/views/users/recent.haml => app/views/users/my.haml (100%) rename web/app/views/users/timeline.haml => app/views/users/recent.haml (100%) create mode 100644 app/views/users/timeline.haml rename web/config.ru => config.ru (100%) rename {web/config => config}/application.rb (100%) rename {web/config => config}/boot.rb (100%) create mode 100644 config/database.yml rename {web/config => config}/environment.rb (100%) rename {web/config => config}/environments/development.rb (100%) rename {web/config => config}/environments/production.rb (98%) rename {web/config => config}/environments/test.rb (100%) rename {web/config => config}/initializers/backtrace_silencers.rb (100%) rename {web/config => config}/initializers/filter_parameter_logging.rb (100%) rename {web/config => config}/initializers/haml.rb (100%) rename {web/config => config}/initializers/inflections.rb (100%) rename {web/config => config}/initializers/mime_types.rb (61%) rename {web/config => config}/initializers/omniauth.rb (100%) rename {web/config => config}/initializers/rails_config.rb (100%) rename {web/config => config}/initializers/secret_token.rb (100%) rename {web/config => config}/initializers/session_store.rb (100%) rename {web/config => config}/initializers/wrap_parameters.rb (100%) rename {web/config => config}/locales/en.yml (100%) create mode 100644 config/routes.rb create mode 100644 config/settings.yml rename {web/config => config}/settings/development.yml (100%) rename {web/config => config}/settings/production.yml (100%) rename {web/config => config}/settings/test.yml (100%) rename {web/db => db}/migrate/20130225123010_create_accounts.rb (100%) rename {web/db => db}/migrate/20130226145932_create_users.rb (100%) rename {web/db => db}/migrate/20130226150329_create_tweets.rb (100%) rename {web/db => db}/migrate/20130226150829_create_favorites.rb (100%) rename {web/db => db}/migrate/20130226151042_create_retweets.rb (100%) rename {web/db => db}/schema.rb (100%) rename {web/db => db}/seeds.rb (100%) create mode 100644 lib/receiver/logger.rb rename {worker => lib}/receiver/worker.rb (73%) rename {web/public => public}/404.xhtml (100%) rename {web/public => public}/422.xhtml (100%) rename {web/public => public}/500.xhtml (100%) rename web/public/assets/application-862b4db892f94edcb21b7275b0a049b0.css => public/assets/application-37cb32f627581ac8bac91345987e7f10.css (84%) create mode 100644 public/assets/application-37cb32f627581ac8bac91345987e7f10.css.gz rename web/public/assets/application-1b8e9e39ac5613519703a2e42949522a.js => public/assets/application-47a9a60feaec5625a9c66b1c985a1179.js (95%) rename web/public/assets/application-1b8e9e39ac5613519703a2e42949522a.js.gz => public/assets/application-47a9a60feaec5625a9c66b1c985a1179.js.gz (77%) create mode 100644 public/assets/bird_gray_16-93f51980875017e26744056b62aaac22.png create mode 100644 public/assets/manifest-0b26a376c9cfe81af432b634628ee75d.json rename {web/public => public}/assets/rails-bc7d436ef8afbf0f88829742a43ba3a4.png (100%) rename {web/public => public}/favicon.ico (100%) rename {web/script => script}/rails (100%) delete mode 100755 start.rb create mode 100644 test/controllers/errors_controller_test.rb create mode 100644 test/helpers/errors_helper_test.rb delete mode 100644 web/Gemfile delete mode 100644 web/Gemfile.lock delete mode 100644 web/README.rdoc delete mode 100644 web/app/controllers/i_controller.rb delete mode 100644 web/app/mailers/.gitkeep delete mode 100644 web/app/models/.gitkeep delete mode 100644 web/app/views/main/index.haml delete mode 100644 web/app/views/users/my.haml delete mode 100644 web/config/database.yml delete mode 100644 web/config/routes.rb delete mode 100644 web/config/settings.yml delete mode 100644 web/lib/assets/.gitkeep delete mode 100644 web/lib/tasks/.gitkeep delete mode 100644 web/log/.gitkeep delete mode 100644 web/public/assets/application-862b4db892f94edcb21b7275b0a049b0.css.gz delete mode 100644 web/public/assets/application-c11f88ddf5d2294cfc1779fcb0be52cf.css delete mode 100644 web/public/assets/application-c11f88ddf5d2294cfc1779fcb0be52cf.css.gz delete mode 100644 web/public/assets/manifest-6b01fb44e2a668d3c0196abd4bdfbb15.json delete mode 100644 web/vendor/assets/javascripts/.gitkeep delete mode 100644 web/vendor/assets/stylesheets/.gitkeep delete mode 100644 web/vendor/plugins/.gitkeep create mode 100755 worker.sh delete mode 100644 worker/receiver.rb delete mode 100644 worker/receiver/logger.rb diff --git a/.gitignore b/.gitignore index 28797c1..538e5ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,26 +1,28 @@ -# See http://help.github.com/ignore-files/ for more about ignoring files. -# -# If you find yourself ignoring temporary files generated by your text editor -# or operating system, you probably want to add a global ignore instead: -# git config --global core.excludesfile ~/.gitignore_global +# Common +**.orig -# Ignore bundler config -.bundle +# Linux +.* +!.gitignore +*~ -# Ignore the default SQLite database. -web/db/*.sqlite3 +# SASS +*.sass-cache +*.sassc -# Ignore all logfiles and tempfiles. -web/log/*.log -web/tmp +# Rails +*.rbc +/vendor/bundle +/log/* +/tmp/* +/spec/tmp/* -web/config/settings.local.yml -web/config/settings/*.local.yml -web/config/environments/*.local.yml -web/config/initializers/secret_token.local.rb +/config/settings.local.yml +/config/settings/*.local.yml +/config/environments/*.local.yml +/config/initializers/secret_token.local.rb # dotcloud /dotcloud.yml /supervisord.conf -.dotcloud diff --git a/Gemfile b/Gemfile deleted file mode 120000 index 02eac92..0000000 --- a/Gemfile +++ /dev/null @@ -1 +0,0 @@ -web/Gemfile \ No newline at end of file diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..14ee69c --- /dev/null +++ b/Gemfile @@ -0,0 +1,25 @@ +ruby '1.9.3' +source 'https://rubygems.org' + +gem 'rails', '4.0.0.beta1' +gem 'mysql2' + +gem 'unicorn' + +gem 'rails_config' +gem 'will_paginate', :github => 're4k/will_paginate' + +group :assets do + gem 'sass-rails', '~> 4.0.0.beta1' + gem 'coffee-rails', '~> 4.0.0.beta1' + gem 'uglifier', '>= 1.0.3' +end + +gem 'therubyracer' +gem 'haml-rails' + +gem 'yajl-ruby', :require => "yajl" +gem 'omniauth-twitter', :github => "re4k/omniauth-twitter" +gem 'em-twitter' +gem 'twitter' + diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 120000 index 4e92a6a..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1 +0,0 @@ -web/Gemfile.lock \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..c38d712 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,174 @@ +GIT + remote: git://github.com/re4k/omniauth-twitter.git + revision: 313df7eb05e78477cf3eb06bced3c9b64957840f + specs: + omniauth-twitter (0.0.14) + multi_json (~> 1.3) + omniauth-oauth (~> 1.0) + +GIT + remote: git://github.com/re4k/will_paginate.git + revision: fcbbd91ced44aaabb1f369875ee9f4f651bc74fb + specs: + will_paginate (3.0.4) + +GEM + remote: https://rubygems.org/ + specs: + actionmailer (4.0.0.beta1) + actionpack (= 4.0.0.beta1) + mail (~> 2.5.3) + actionpack (4.0.0.beta1) + activesupport (= 4.0.0.beta1) + builder (~> 3.1.0) + erubis (~> 2.7.0) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + activemodel (4.0.0.beta1) + activesupport (= 4.0.0.beta1) + builder (~> 3.1.0) + activerecord (4.0.0.beta1) + activemodel (= 4.0.0.beta1) + activerecord-deprecated_finders (~> 0.0.3) + activesupport (= 4.0.0.beta1) + arel (~> 4.0.0.beta1) + activerecord-deprecated_finders (0.0.3) + activesupport (4.0.0.beta1) + i18n (~> 0.6.2) + minitest (~> 4.2) + multi_json (~> 1.3) + thread_safe (~> 0.1) + tzinfo (~> 0.3.33) + arel (4.0.0.beta1) + atomic (1.0.1) + builder (3.1.4) + coffee-rails (4.0.0.beta1) + coffee-script (>= 2.2.0) + railties (>= 4.0.0.beta, < 5.0) + coffee-script (2.2.0) + coffee-script-source + execjs + coffee-script-source (1.6.1) + em-twitter (0.2.1) + eventmachine (~> 1.0) + http_parser.rb (~> 0.5) + simple_oauth (~> 0.1) + erubis (2.7.0) + eventmachine (1.0.1) + execjs (1.4.0) + multi_json (~> 1.0) + faraday (0.8.6) + multipart-post (~> 1.1) + haml (4.0.0) + tilt + haml-rails (0.4) + actionpack (>= 3.1, < 4.1) + activesupport (>= 3.1, < 4.1) + haml (>= 3.1, < 4.1) + railties (>= 3.1, < 4.1) + hashie (1.2.0) + hike (1.2.1) + http_parser.rb (0.5.3) + i18n (0.6.4) + json (1.7.7) + kgio (2.8.0) + libv8 (3.11.8.13) + mail (2.5.3) + i18n (>= 0.4.0) + mime-types (~> 1.16) + treetop (~> 1.4.8) + mime-types (1.21) + minitest (4.6.2) + multi_json (1.6.1) + multipart-post (1.2.0) + mysql2 (0.3.11) + oauth (0.4.7) + omniauth (1.1.3) + hashie (~> 1.2) + rack + omniauth-oauth (1.0.1) + oauth + omniauth (~> 1.0) + polyglot (0.3.3) + rack (1.5.2) + rack-test (0.6.2) + rack (>= 1.0) + rails (4.0.0.beta1) + actionmailer (= 4.0.0.beta1) + actionpack (= 4.0.0.beta1) + activerecord (= 4.0.0.beta1) + activesupport (= 4.0.0.beta1) + bundler (>= 1.3.0, < 2.0) + railties (= 4.0.0.beta1) + sprockets-rails (~> 2.0.0.rc3) + rails_config (0.3.2) + activesupport (>= 3.0) + railties (4.0.0.beta1) + actionpack (= 4.0.0.beta1) + activesupport (= 4.0.0.beta1) + rake (>= 0.8.7) + rdoc (~> 3.4) + thor (>= 0.17.0, < 2.0) + raindrops (0.10.0) + rake (10.0.3) + rdoc (3.12.2) + json (~> 1.4) + ref (1.0.2) + sass (3.2.6) + sass-rails (4.0.0.beta1) + railties (>= 4.0.0.beta, < 5.0) + sass (>= 3.1.10) + sprockets-rails (~> 2.0.0.rc0) + tilt (~> 1.3) + simple_oauth (0.2.0) + sprockets (2.9.0) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sprockets-rails (2.0.0.rc3) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (~> 2.8) + therubyracer (0.11.4) + libv8 (~> 3.11.8.12) + ref + thor (0.17.0) + thread_safe (0.1.0) + atomic + tilt (1.3.4) + treetop (1.4.12) + polyglot + polyglot (>= 0.3.1) + twitter (4.5.0) + faraday (~> 0.8, < 0.10) + multi_json (~> 1.0) + simple_oauth (~> 0.2) + tzinfo (0.3.36) + uglifier (1.3.0) + execjs (>= 0.3.0) + multi_json (~> 1.0, >= 1.0.2) + unicorn (4.6.2) + kgio (~> 2.6) + rack + raindrops (~> 0.7) + yajl-ruby (1.1.0) + +PLATFORMS + ruby + +DEPENDENCIES + coffee-rails (~> 4.0.0.beta1) + em-twitter + haml-rails + mysql2 + omniauth-twitter! + rails (= 4.0.0.beta1) + rails_config + sass-rails (~> 4.0.0.beta1) + therubyracer + twitter + uglifier (>= 1.0.3) + unicorn + will_paginate! + yajl-ruby diff --git a/README.md b/README.md new file mode 100644 index 0000000..935a68f --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# Aclog +Collects favs and retweets in real time by UserStreams. +A web service like Favstar. + +## Aclog is +* Powered by Ruby on Rails +* Free and open source (MIT License) + +## Status +* Working on ![aclog-re4k.dotcloud.com](aclog-re4k.dotcloud.com) for testing. + +## Requirements +* Ruby 1.9.3+ +* MySQL or SQLite + +## Installation (dotCloud) +1. + + git clone https://github.com/re4k/aclog.git + bundle + + dotcloud push + *~(**)~* + +2. + + cp dotcloud.yml.sample dotcloud.yml + (Edit) + +3. + + cp config/settings.yml.sample config/settings.yml + (Edit) +3. + + (今度書きます..) + diff --git a/web/Rakefile b/Rakefile similarity index 100% rename from web/Rakefile rename to Rakefile diff --git a/app/assets/images/bird_gray_16.png b/app/assets/images/bird_gray_16.png new file mode 100644 index 0000000000000000000000000000000000000000..8cf5afa6e34999512091ef78ce6edfe27e4bffe1 GIT binary patch literal 1106 zcmaJ=OK1~87@nG_wW8F5#fs>#iYK#=bdx4)W1D6h8*yt$qxK@W*_|e9-JR|3)NJde zz7C2)@gNEws+3YZh#+2kV8I@IK~eOe=s^@cYN6mkMQ3YMJs1~eXXfYszW?>j>1_AT zRdws@0065pU2=}@tLa)c*+W=yq+a!A#O1|FeS z00LW#d@t!$c1s#IS=IMpJ=3OW09xBTTh;mzfdy1FtOWD<&V2?NdV<*>QFz5pp_0)x z?4X|E?z}eKuf=tyZ3k@iBuZc+qC(F+Y`Kz`VCH!xdiKp61Ls{xe}eg)RIieSDeNE^ zVfm28M+F!aSwZCEVtgA6^8(KaVUBMJ3A_|(k$3?vd<>1|=zUU7PA|lww**rn#FjX& zTrRWaW)?d|PKd|j93SSw;Slu*xkDCFy^!T@t}w{R)f~en2DYHjs21=bNia0i-zAv# zBCX{vw23y1^HiG?Sl%zG;;1P9cQwsLZ_1*`wTwp7LXVlZtQSw@a=1nFr9n{d8p z$*7)-Se0)9t5?q@QWeY5WH^7ce~r3gqWbZVi^8RsMd>4p>fNEjp1HL#NFT*?Mo#9v z*M;vtf3`h%b+fqi?74Go{8-IsY;+eW)c*jJeKq;B$JSgMNQ~ZFv*p;tZ0l&ay+H!g zb?t8+2G@d1;Z2kFj;As-MismD|A literal 0 HcmV?d00001 diff --git a/web/app/assets/images/rails.png b/app/assets/images/rails.png similarity index 100% rename from web/app/assets/images/rails.png rename to app/assets/images/rails.png diff --git a/web/app/assets/javascripts/application.js b/app/assets/javascripts/application.js similarity index 100% rename from web/app/assets/javascripts/application.js rename to app/assets/javascripts/application.js diff --git a/app/assets/javascripts/errors.js.coffee b/app/assets/javascripts/errors.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/errors.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/web/app/assets/javascripts/i.js.coffee b/app/assets/javascripts/i.js.coffee similarity index 100% rename from web/app/assets/javascripts/i.js.coffee rename to app/assets/javascripts/i.js.coffee diff --git a/web/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee similarity index 100% rename from web/app/assets/javascripts/main.js.coffee rename to app/assets/javascripts/main.js.coffee diff --git a/web/app/assets/javascripts/sessions.js.coffee b/app/assets/javascripts/sessions.js.coffee similarity index 100% rename from web/app/assets/javascripts/sessions.js.coffee rename to app/assets/javascripts/sessions.js.coffee diff --git a/web/app/assets/javascripts/users.js.coffee b/app/assets/javascripts/users.js.coffee similarity index 100% rename from web/app/assets/javascripts/users.js.coffee rename to app/assets/javascripts/users.js.coffee diff --git a/web/app/assets/stylesheets/_tweets.css.sass b/app/assets/stylesheets/_tweets.css.sass similarity index 89% rename from web/app/assets/stylesheets/_tweets.css.sass rename to app/assets/stylesheets/_tweets.css.sass index 2a19662..a1f0cb3 100644 --- a/web/app/assets/stylesheets/_tweets.css.sass +++ b/app/assets/stylesheets/_tweets.css.sass @@ -26,11 +26,12 @@ .user :padding 0 5px 15px :font-weight bold - :color #666666 .name :font-size 14px .screen_name :font-size 12px + a + :color #666666 .text :font-size 18px :line-height 25px @@ -40,6 +41,13 @@ :padding 0 5px 15px :color #666666 :font-size 12px + .twitter_bird + :display block + :float left + img + :vertical-align top + :margin-right 2px + :margin-top 1px .created_at :display block :float left diff --git a/web/app/assets/stylesheets/application.css.sass b/app/assets/stylesheets/application.css.sass similarity index 69% rename from web/app/assets/stylesheets/application.css.sass rename to app/assets/stylesheets/application.css.sass index 162d62a..cd8dc0f 100644 --- a/web/app/assets/stylesheets/application.css.sass +++ b/app/assets/stylesheets/application.css.sass @@ -3,9 +3,12 @@ * :margin 0 :padding 0 + :font-family "Ubuntu", sans-serif a :text-decoration none - :color inherit + :color #3b5998 +img + :border none .clearfix:after :content "." :visibility hidden diff --git a/app/assets/stylesheets/errors.css.scss b/app/assets/stylesheets/errors.css.scss new file mode 100644 index 0000000..5b23d97 --- /dev/null +++ b/app/assets/stylesheets/errors.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the errors controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/web/app/controllers/application_controller.rb b/app/controllers/application_controller.rb similarity index 60% rename from web/app/controllers/application_controller.rb rename to app/controllers/application_controller.rb index 15abd84..d07e636 100644 --- a/web/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,9 +1,11 @@ class ApplicationController < ActionController::Base protect_from_forgery - before_filter :set_content_type + after_filter :set_content_type def set_content_type - request.format = :xhtml if request.format == :html + if request.format == :html + response.content_type = "application/xhtml+xml" + end end def get_page_number(params) @@ -17,8 +19,8 @@ def get_page_number(params) def get_user_cache(items) Hash[ - User.find(@items - .map{|m| m.favorites.map{|u| u.user_id} + m.retweets.map{|u| u.user_id}} + User.find(items + .map{|m| [m.user_id, m.favorites.map{|u| u.user_id}, m.retweets.map{|u| u.user_id}]} .flatten .uniq) .map{|m| [m.id, m]} diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb new file mode 100644 index 0000000..170f2aa --- /dev/null +++ b/app/controllers/errors_controller.rb @@ -0,0 +1,7 @@ +class ErrorsController < ApplicationController + def error_404 + end + + def error_500 + end +end diff --git a/app/controllers/i_controller.rb b/app/controllers/i_controller.rb new file mode 100644 index 0000000..c1a66f4 --- /dev/null +++ b/app/controllers/i_controller.rb @@ -0,0 +1,8 @@ +class IController < ApplicationController + def show + id = params[:id].to_i + @item = Tweet.find_by(:id => id) + @user_cache = get_user_cache([@item]) + @title = "\"#{ApplicationController.helpers.strip_tags(ApplicationController.helpers.format_tweet_text(@item.text))[0...30]}\" from @#{@user_cache[@item.user_id].screen_name}" + end +end diff --git a/web/app/controllers/main_controller.rb b/app/controllers/main_controller.rb similarity index 100% rename from web/app/controllers/main_controller.rb rename to app/controllers/main_controller.rb diff --git a/web/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb similarity index 100% rename from web/app/controllers/sessions_controller.rb rename to app/controllers/sessions_controller.rb diff --git a/web/app/controllers/users_controller.rb b/app/controllers/users_controller.rb similarity index 68% rename from web/app/controllers/users_controller.rb rename to app/controllers/users_controller.rb index c1a2718..5b5995f 100644 --- a/web/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -12,7 +12,7 @@ def best @items = [] end @user_cache = get_user_cache(@items) - @title = "Best tweets of #{screen_name} page #{page}" + @title = "@#{screen_name}'s Best Tweets" end def recent @@ -28,7 +28,7 @@ def recent @items = [] end @user_cache = get_user_cache(@items) - @title = "Recent faved of #{screen_name} page #{page}" + @title = "@#{screen_name}'s Newest Tweets" end def timeline @@ -43,7 +43,7 @@ def timeline @items = [] end @user_cache = get_user_cache(@items) - @title = "User timeline of #{screen_name} page #{page}" + @title = "@#{screen_name}'s Newest Tweets" end def my @@ -51,26 +51,20 @@ def my screen_name = params[:screen_name] user = User.find_by(:screen_name => screen_name) if user - tweet_ids = ActiveRecord::Base.connection.execute( - "SELECT * FROM (" + - "SELECT tweet_id FROM favorites WHERE user_id = #{user.id} " + - "UNION " + - "SELECT tweet_id FROM retweets WHERE user_id = #{user.id}" + - ") rf " + - "ORDER BY 1 DESC " + - "LIMIT #{Settings.page_per} " + - "OFFSET #{Settings.page_per * (page - 1)};") - tweet_ids.map!{|m| m.values[0]} - if tweet_ids && tweet_ids.size > 0 - @items = Tweet.find(tweet_ids, :order => "id DESC") - else - @items = [] - end + @items = Tweet + .where("id IN (SELECT tweet_id FROM (" + + "SELECT tweet_id FROM favorites WHERE user_id = #{user.id} " + + "UNION " + + "SELECT tweet_id FROM retweets WHERE user_id = #{user.id}" + + ") AS rf)") + .order("id DESC") + .paginate(:page => page, :per_page => Settings.page_per) + else @items = [] end @user_cache = get_user_cache(@items) - @title = "Favs from #{screen_name} page #{page}" + @title = "@#{screen_name}'s Recent Discoveries" end def info diff --git a/web/app/helpers/application_helper.rb b/app/helpers/application_helper.rb similarity index 56% rename from web/app/helpers/application_helper.rb rename to app/helpers/application_helper.rb index 44920d5..bb410cd 100644 --- a/web/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -8,7 +8,7 @@ def format_tweet_created_at(dt) def format_tweet_text(text) text .gsub(//){link_to($2, $1, :target => "_blank")} - .gsub(//){link_to("##{$1}", "https://twitter.com/search?q=%23#{$1}")} + .gsub(//){link_to("##{URI.decode($1)}", "https://twitter.com/search?q=%23#{$1}")} .gsub(//){link_to("@#{$1}", "/#{$1}")} .gsub(/\r\n|\r|\n/, "
") end @@ -18,10 +18,14 @@ def format_source_text(text) end def status_url(tweet) - "https://twitter.com/#{tweet.user.screen_name}/status/#{tweet.id}" + "/#{@user_cache[tweet.user_id].screen_name}/status/#{tweet.id}" end - def user_url(user) - "/#{user.screen_name}" + def twitter_status_url(tweet) + "https://twitter.com/#{@user_cache[tweet.user_id].screen_name}/status/#{tweet.id}" + end + + def user_url(user_id) + "/#{@user_cache[user_id].screen_name}" end end diff --git a/app/helpers/errors_helper.rb b/app/helpers/errors_helper.rb new file mode 100644 index 0000000..8e3b415 --- /dev/null +++ b/app/helpers/errors_helper.rb @@ -0,0 +1,2 @@ +module ErrorsHelper +end diff --git a/web/app/helpers/i_helper.rb b/app/helpers/i_helper.rb similarity index 100% rename from web/app/helpers/i_helper.rb rename to app/helpers/i_helper.rb diff --git a/web/app/helpers/main_helper.rb b/app/helpers/main_helper.rb similarity index 100% rename from web/app/helpers/main_helper.rb rename to app/helpers/main_helper.rb diff --git a/web/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb similarity index 100% rename from web/app/helpers/sessions_helper.rb rename to app/helpers/sessions_helper.rb diff --git a/web/app/helpers/users_helper.rb b/app/helpers/users_helper.rb similarity index 100% rename from web/app/helpers/users_helper.rb rename to app/helpers/users_helper.rb diff --git a/web/app/models/account.rb b/app/models/account.rb similarity index 100% rename from web/app/models/account.rb rename to app/models/account.rb diff --git a/web/app/models/favorite.rb b/app/models/favorite.rb similarity index 100% rename from web/app/models/favorite.rb rename to app/models/favorite.rb diff --git a/web/app/models/retweet.rb b/app/models/retweet.rb similarity index 100% rename from web/app/models/retweet.rb rename to app/models/retweet.rb diff --git a/web/app/models/tweet.rb b/app/models/tweet.rb similarity index 100% rename from web/app/models/tweet.rb rename to app/models/tweet.rb diff --git a/web/app/models/user.rb b/app/models/user.rb similarity index 100% rename from web/app/models/user.rb rename to app/models/user.rb diff --git a/app/views/errors/error_404.html.haml b/app/views/errors/error_404.html.haml new file mode 100644 index 0000000..4f574e3 --- /dev/null +++ b/app/views/errors/error_404.html.haml @@ -0,0 +1 @@ +%h2 404 diff --git a/app/views/errors/error_500.html.haml b/app/views/errors/error_500.html.haml new file mode 100644 index 0000000..e3712eb --- /dev/null +++ b/app/views/errors/error_500.html.haml @@ -0,0 +1 @@ +%h2 500 diff --git a/web/app/views/i/show.haml b/app/views/i/show.haml similarity index 63% rename from web/app/views/i/show.haml rename to app/views/i/show.haml index dfb6b20..c712cdc 100644 --- a/web/app/views/i/show.haml +++ b/app/views/i/show.haml @@ -1,3 +1,3 @@ -.content - = render :partial => "shared/tweet", :locals => {:item => @item} +.items + = render :partial => "shared/tweet", :locals => {:item => @item, :user_cache => @user_cache} diff --git a/web/app/views/layouts/application.haml b/app/views/layouts/application.haml similarity index 100% rename from web/app/views/layouts/application.haml rename to app/views/layouts/application.haml diff --git a/app/views/main/index.haml b/app/views/main/index.haml new file mode 100644 index 0000000..b0e1b79 --- /dev/null +++ b/app/views/main/index.haml @@ -0,0 +1,23 @@ +%p + %strong (´へεへ`*) < トップページだよ〜〜 +%p + Favstar クローンです。UserStreams つかってます。 + = link_to "@KOBA789", "https://twitter.com/KOBA789" + さんにサーバーを貸していただけることになりました…!! +%strong まだ開発途中段階のものですがとりあえず動いています。登録後接続まで最大30分かかります。 +%strong 動作のテスト中ですので、途中で登録をうちきったりあまりにふぁぼられ・ふぁぼりが多いユーザーの登録を削除する可能性もあります。 +%div + URLとかについて + %div + best: + = link_to "(/users)/re4k", "/re4k" + %div + recent: + = link_to "(/users)/re4k/recent", "/re4k/recent" + %div + こんどほかのところもFavstar互換にする +%div + デザインなんとかしないと... +%div + = link_to "@re4k", "https://twitter.com/re4k" + diff --git a/web/app/views/shared/_tweet.haml b/app/views/shared/_tweet.haml similarity index 52% rename from web/app/views/shared/_tweet.haml rename to app/views/shared/_tweet.haml index 3780200..c43bf62 100644 --- a/web/app/views/shared/_tweet.haml +++ b/app/views/shared/_tweet.haml @@ -1,20 +1,20 @@ .item .tweet .avatar - %a{href: user_url(item.user)} - %img{src: item.user.profile_image_url} + %a{href: user_url(item.user_id)} + %img{src: user_cache[item.user_id].profile_image_url} .tweet_content_fix .tweet_content .user %span.name - = link_to item.user.name, user_url(item.user) + = link_to user_cache[item.user_id].name, user_url(item.user_id) %span.screen_name - = link_to "@#{item.user.screen_name}", user_url(item.user) + = link_to "@#{user_cache[item.user_id].screen_name}", user_url(item.user_id) .text = raw format_tweet_text(item.text) .meta.clearfix - %span.created_at - = link_to format_tweet_created_at(item.tweeted_at), status_url(item) + = link_to image_tag("bird_gray_16.png"), twitter_status_url(item), :target => "_blank", :class => "twitter_bird" + = link_to format_tweet_created_at(item.tweeted_at), status_url(item), :class => "created_at" %span.source = raw format_source_text(item.source) .stats @@ -25,10 +25,10 @@ %span.type= type .users_content_fix .users_content - - data.map{|m| @user_cache[m.user_id]}.each_slice(10) do |row| + - data.map{|m| user_cache[m.user_id]}.each_slice(10) do |row| %ul.users_row.clearfix - row.each do |u| %li - %a{href: user_url(u)}>< + %a{href: user_url(u.id)}>< %img{src: u.profile_image_url} diff --git a/web/app/views/shared/_tweets.haml b/app/views/shared/_tweets.haml similarity index 65% rename from web/app/views/shared/_tweets.haml rename to app/views/shared/_tweets.haml index 719185d..57149ed 100644 --- a/web/app/views/shared/_tweets.haml +++ b/app/views/shared/_tweets.haml @@ -1,4 +1,4 @@ -%div.items - = render :partial => "shared/tweet", :collection => items, :as => :item +.items + = render :partial => "shared/tweet", :collection => items, :as => :item, :locals => {:user_cache => @user_cache} - if items.size > 0 = will_paginate items diff --git a/web/app/views/users/best.haml b/app/views/users/best.haml similarity index 100% rename from web/app/views/users/best.haml rename to app/views/users/best.haml diff --git a/web/app/views/users/info.haml b/app/views/users/info.haml similarity index 100% rename from web/app/views/users/info.haml rename to app/views/users/info.haml diff --git a/web/app/views/users/recent.haml b/app/views/users/my.haml similarity index 100% rename from web/app/views/users/recent.haml rename to app/views/users/my.haml diff --git a/web/app/views/users/timeline.haml b/app/views/users/recent.haml similarity index 100% rename from web/app/views/users/timeline.haml rename to app/views/users/recent.haml diff --git a/app/views/users/timeline.haml b/app/views/users/timeline.haml new file mode 100644 index 0000000..2672287 --- /dev/null +++ b/app/views/users/timeline.haml @@ -0,0 +1 @@ += render :partial => "shared/tweets", :locals => {:items => @items} diff --git a/web/config.ru b/config.ru similarity index 100% rename from web/config.ru rename to config.ru diff --git a/web/config/application.rb b/config/application.rb similarity index 100% rename from web/config/application.rb rename to config/application.rb diff --git a/web/config/boot.rb b/config/boot.rb similarity index 100% rename from web/config/boot.rb rename to config/boot.rb diff --git a/config/database.yml b/config/database.yml new file mode 100644 index 0000000..b2b0606 --- /dev/null +++ b/config/database.yml @@ -0,0 +1,16 @@ +<% #development: + + #test: +%> + +production: + adapter: mysql2 + encoding: utf8 + reconnect: true + database: production + pool: 5 + username: <%= ENV["DOTCLOUD_DB_MYSQL_LOGIN"] %> + password: <%= ENV["DOTCLOUD_DB_MYSQL_PASSWORD"] %> + host: <%= ENV["DOTCLOUD_DB_MYSQL_HOST"] %> + port: <%= ENV["DOTCLOUD_DB_MYSQL_PORT"] %> + diff --git a/web/config/environment.rb b/config/environment.rb similarity index 100% rename from web/config/environment.rb rename to config/environment.rb diff --git a/web/config/environments/development.rb b/config/environments/development.rb similarity index 100% rename from web/config/environments/development.rb rename to config/environments/development.rb diff --git a/web/config/environments/production.rb b/config/environments/production.rb similarity index 98% rename from web/config/environments/production.rb rename to config/environments/production.rb index 7ba398c..c219686 100644 --- a/web/config/environments/production.rb +++ b/config/environments/production.rb @@ -20,7 +20,7 @@ # config.action_dispatch.rack_cache = true # Disable Rails's static asset server (Apache or nginx will already do this). - config.serve_static_assets = false + config.serve_static_assets = true # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier diff --git a/web/config/environments/test.rb b/config/environments/test.rb similarity index 100% rename from web/config/environments/test.rb rename to config/environments/test.rb diff --git a/web/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb similarity index 100% rename from web/config/initializers/backtrace_silencers.rb rename to config/initializers/backtrace_silencers.rb diff --git a/web/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb similarity index 100% rename from web/config/initializers/filter_parameter_logging.rb rename to config/initializers/filter_parameter_logging.rb diff --git a/web/config/initializers/haml.rb b/config/initializers/haml.rb similarity index 100% rename from web/config/initializers/haml.rb rename to config/initializers/haml.rb diff --git a/web/config/initializers/inflections.rb b/config/initializers/inflections.rb similarity index 100% rename from web/config/initializers/inflections.rb rename to config/initializers/inflections.rb diff --git a/web/config/initializers/mime_types.rb b/config/initializers/mime_types.rb similarity index 61% rename from web/config/initializers/mime_types.rb rename to config/initializers/mime_types.rb index 6e2831e..72aca7e 100644 --- a/web/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -1,10 +1,5 @@ # Be sure to restart your server when you modify this file. -module Mime - remove_const("HTML") -end + # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone -Mime::Type.register "text/html", :html -Mime::Type.register "application/xhtml+xml", :xhtml - diff --git a/web/config/initializers/omniauth.rb b/config/initializers/omniauth.rb similarity index 100% rename from web/config/initializers/omniauth.rb rename to config/initializers/omniauth.rb diff --git a/web/config/initializers/rails_config.rb b/config/initializers/rails_config.rb similarity index 100% rename from web/config/initializers/rails_config.rb rename to config/initializers/rails_config.rb diff --git a/web/config/initializers/secret_token.rb b/config/initializers/secret_token.rb similarity index 100% rename from web/config/initializers/secret_token.rb rename to config/initializers/secret_token.rb diff --git a/web/config/initializers/session_store.rb b/config/initializers/session_store.rb similarity index 100% rename from web/config/initializers/session_store.rb rename to config/initializers/session_store.rb diff --git a/web/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb similarity index 100% rename from web/config/initializers/wrap_parameters.rb rename to config/initializers/wrap_parameters.rb diff --git a/web/config/locales/en.yml b/config/locales/en.yml similarity index 100% rename from web/config/locales/en.yml rename to config/locales/en.yml diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..609e7fd --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,21 @@ +Aclog::Application.routes.draw do + constraints = { + :id => /[0-9]+/, + :screen_name => /[a-zA-Z0-9_]{1,20}/, + :page => /[0-9]+/, + } + + root :to => "main#index" + get "i/callback" => "sessions#callback" + get "i/logout" => "sessions#destroy" + + get "i/:id" => "i#show", :constraints => constraints + get "(users)/:screen_name/status(es)/:id" => "i#show", :constraints => constraints + + get "(users)/:screen_name(/:page)" => "users#best", :constraints => constraints + get "(users)/:screen_name/my(/:page)" => "users#my", :constraints => constraints + get "(users)/:screen_name/discovered(/:page)" => "users#my", :constraints => constraints + get "(users)/:screen_name/timeline(/:page)" => "users#timeline", :constraints => constraints + get "(users)/:screen_name/recent(/:page)" => "users#recent", :constraints => constraints + get "(users)/:screen_name/info(/:page)" => "users#info", :constraints => constraints +end diff --git a/config/settings.yml b/config/settings.yml new file mode 100644 index 0000000..b93d958 --- /dev/null +++ b/config/settings.yml @@ -0,0 +1,12 @@ +<% +# dotCloud +env_file = "/home/dotcloud/environment.json" +if File.exists?(env_file) + ENV.update(Hash[JSON.parse(File.read(env_file)).map{|k, v| [k.to_s, v.to_s]}]) +end +%> +consumer_key: <%= ENV["CONSUMER_KEY"] %> +consumer_secret: <%= ENV["CONSUMER_SECRET"] %> +worker_count: <%= ENV["WORKER_COUNT"] %> +dotcloud_service_name: <%= ENV["DOTCLOUD_SERVICE_NAME"] %> +page_per: 10 diff --git a/web/config/settings/development.yml b/config/settings/development.yml similarity index 100% rename from web/config/settings/development.yml rename to config/settings/development.yml diff --git a/web/config/settings/production.yml b/config/settings/production.yml similarity index 100% rename from web/config/settings/production.yml rename to config/settings/production.yml diff --git a/web/config/settings/test.yml b/config/settings/test.yml similarity index 100% rename from web/config/settings/test.yml rename to config/settings/test.yml diff --git a/web/db/migrate/20130225123010_create_accounts.rb b/db/migrate/20130225123010_create_accounts.rb similarity index 100% rename from web/db/migrate/20130225123010_create_accounts.rb rename to db/migrate/20130225123010_create_accounts.rb diff --git a/web/db/migrate/20130226145932_create_users.rb b/db/migrate/20130226145932_create_users.rb similarity index 100% rename from web/db/migrate/20130226145932_create_users.rb rename to db/migrate/20130226145932_create_users.rb diff --git a/web/db/migrate/20130226150329_create_tweets.rb b/db/migrate/20130226150329_create_tweets.rb similarity index 100% rename from web/db/migrate/20130226150329_create_tweets.rb rename to db/migrate/20130226150329_create_tweets.rb diff --git a/web/db/migrate/20130226150829_create_favorites.rb b/db/migrate/20130226150829_create_favorites.rb similarity index 100% rename from web/db/migrate/20130226150829_create_favorites.rb rename to db/migrate/20130226150829_create_favorites.rb diff --git a/web/db/migrate/20130226151042_create_retweets.rb b/db/migrate/20130226151042_create_retweets.rb similarity index 100% rename from web/db/migrate/20130226151042_create_retweets.rb rename to db/migrate/20130226151042_create_retweets.rb diff --git a/web/db/schema.rb b/db/schema.rb similarity index 100% rename from web/db/schema.rb rename to db/schema.rb diff --git a/web/db/seeds.rb b/db/seeds.rb similarity index 100% rename from web/db/seeds.rb rename to db/seeds.rb diff --git a/lib/receiver/logger.rb b/lib/receiver/logger.rb new file mode 100644 index 0000000..e1ecf56 --- /dev/null +++ b/lib/receiver/logger.rb @@ -0,0 +1,42 @@ +class Receiver::Logger + def debug(msg) + if @level == :debug + log(@out, "DEBUG", msg) + end + end + + def info(msg) + unless @level == :none + @level == :error + @level == :warn + log(@out, "INFO", msg) + end + end + + def warn(msg) + unless @level == :none + @level == :error + log(@err, "WARN", msg) + end + end + + def error(msg) + unless @level == :none + log(@err, "ERROR", msg) + end + end + + def fatal(msg) + log(@err, "FATAL", msg) + end + + def log(out, type, msg) + out.puts Time.now.utc.iso8601(3) + " " + type + ": " + msg.to_s + end + + def initialize(level = :warn) + @out = STDOUT + @err = STDERR + @level = level + end +end diff --git a/worker/receiver/worker.rb b/lib/receiver/worker.rb similarity index 73% rename from worker/receiver/worker.rb rename to lib/receiver/worker.rb index 7abc9d5..5d5f60b 100644 --- a/worker/receiver/worker.rb +++ b/lib/receiver/worker.rb @@ -2,7 +2,15 @@ class Receiver::Worker def initialize - @logger = Receiver::Logger.instance + @logger = Receiver::Logger.new(:info) + @connections = [] + + _tm = Settings.dotcloud_service_name.split(/_/).last + if _tm =~ /^[0-9]+$/ + @worker_number = Integer(_tm) + else + exit(0) + end end # Create Aclog format text from Twitter Status Hash @@ -34,56 +42,75 @@ def format_text_from_hash(hash) return text end + def rescue_duplicate(&proc) + begin + return proc.call + rescue ActiveRecord::StatementInvalid => e + if e.to_s =~ /^Mysql2::Error: Duplicate entry / + @logger.info("Duplicate entry..") + else + raise e + end + end + end + # Create or Update user by Twitter User Hash def create_user_from_hash(user) - rec = User.find_or_initialize_by(:id => user[:id]) - rec.screen_name = user[:screen_name] - rec.name = user[:name] - rec.profile_image_url = user[:profile_image_url_https] - rec.save! if rec.changed? - - return rec + rescue_duplicate do + rec = User.find_or_initialize_by(:id => user[:id]) + rec.screen_name = user[:screen_name] + rec.name = user[:name] + rec.profile_image_url = user[:profile_image_url_https] + rec.save! if rec.changed? + + return rec + end end # Create tweet by Twitter Status Hash def create_tweet_from_hash(status) - Tweet.find_by(:id => status[:id]) || - Tweet.create!(:id => status[:id], - :text => format_text_from_hash(status), - :source => status[:source], - :tweeted_at => Time.parse(status[:created_at]), - :user => create_user_from_hash(status[:user])) + rescue_duplicate do + Tweet.find_by(:id => status[:id]) || + Tweet.create!(:id => status[:id], + :text => format_text_from_hash(status), + :source => status[:source], + :tweeted_at => Time.parse(status[:created_at]), + :user => create_user_from_hash(status[:user])) + end end def destroy_tweet_from_hash(status) - Tweet.delete(status[:delete][:status][:id]) + Tweet.delete(status[:delete][:status][:id]) || + Retweet.delete(status[:delete][:status][:id]) end # Create Retweet by Twitter Status Hash def create_retweet_from_hash(status) - Retweet.find_by(:id => status[:id]) || - Retweet.create!(:id => status[:id], - :tweet => create_tweet_from_hash(status[:retweeted_status]), - :user => create_user_from_hash(status[:user])) + rescue_duplicate do + Retweet.find_by(:id => status[:id]) || + Retweet.create!(:id => status[:id], + :tweet => create_tweet_from_hash(status[:retweeted_status]), + :user => create_user_from_hash(status[:user])) + end end # Create Favorite by Streaming Event Hash def create_favorite_from_hash(status) - user = create_user_from_hash(status[:source]) - user.favorites.find_by(:tweet_id => status[:target_object][:id]) || - user.favorites.create!(:tweet => create_tweet_from_hash(status[:target_object])) + rescue_duplicate do + user = create_user_from_hash(status[:source]) + user.favorites.find_by(:tweet_id => status[:target_object][:id]) || + user.favorites.create!(:tweet => create_tweet_from_hash(status[:target_object])) + end end def destroy_favorite_from_hash(status) - Favorite.delete_all("tweet_id = #{status[:target_object][:id]} AND " + - "user_id = #{status[:source][:id]}") + create_tweet_from_hash(status[:target_object]) + .favorites.where(:user_id => status[:source][:id]).delete_all end def start + @logger.info("Worker ##{@worker_number} started") EM.run do - # UserStreams connections - @connections = [] - stop = Proc.new do @connections.map(&:stop) EM.stop @@ -141,6 +168,7 @@ def start con.on_enhance_your_calm do @logger.error("Enhance Your Calm: #{con.options[:user_id]}") + @connections.delete(con) end con.on_error do |message| @@ -201,35 +229,9 @@ def start @connections << con end - # EventReceiver - #EM.start_server("127.0.0.1", Settings.worker_port) do |server| - # def server.receive_data(data) - # d = data.split(/ /) - - # if handle_event(d[0].to_sym, s[1].to_i) - # send_data "Accepted\r\n" - # else - # send_data "Denied\r\n" - # end - - # close_connection_after_writing - # end - - # def handle_event(command, id) - # case command - # when :REGISTER - # if account = Account.find_by(:id => id) - # register.call(account) - # return true - # else - # return false - # end - # end - # end - #end - reconnect = -> do - Account.all.each do |account| + Account.where("id % #{Settings.worker_count} = #{@worker_number}").each do |account| + #Account.find_by_sql("SELECT * FROM accounts WHERE id % #{Settings.worker_count} = #{@worker_number}").each do |account| if con = @connections.find{|m| m.options[:user_id] == account.id} con.immediate_reconnect else diff --git a/web/public/404.xhtml b/public/404.xhtml similarity index 100% rename from web/public/404.xhtml rename to public/404.xhtml diff --git a/web/public/422.xhtml b/public/422.xhtml similarity index 100% rename from web/public/422.xhtml rename to public/422.xhtml diff --git a/web/public/500.xhtml b/public/500.xhtml similarity index 100% rename from web/public/500.xhtml rename to public/500.xhtml diff --git a/web/public/assets/application-862b4db892f94edcb21b7275b0a049b0.css b/public/assets/application-37cb32f627581ac8bac91345987e7f10.css similarity index 84% rename from web/public/assets/application-862b4db892f94edcb21b7275b0a049b0.css rename to public/assets/application-37cb32f627581ac8bac91345987e7f10.css index 8b14231..ba54105 100644 --- a/web/public/assets/application-862b4db892f94edcb21b7275b0a049b0.css +++ b/public/assets/application-37cb32f627581ac8bac91345987e7f10.css @@ -24,12 +24,13 @@ width: 473px; } .items .item .tweet .tweet_content .user { padding: 0 5px 15px; - font-weight: bold; - color: #666666; } + font-weight: bold; } .items .item .tweet .tweet_content .user .name { font-size: 14px; } .items .item .tweet .tweet_content .user .screen_name { font-size: 12px; } + .items .item .tweet .tweet_content .user a { + color: #666666; } .items .item .tweet .tweet_content .text { font-size: 18px; line-height: 25px; @@ -39,6 +40,13 @@ padding: 0 5px 15px; color: #666666; font-size: 12px; } + .items .item .tweet .tweet_content .meta .twitter_bird { + display: block; + float: left; } + .items .item .tweet .tweet_content .meta .twitter_bird img { + vertical-align: top; + margin-right: 2px; + margin-top: 1px; } .items .item .tweet .tweet_content .meta .created_at { display: block; float: left; } @@ -79,11 +87,15 @@ * { margin: 0; - padding: 0; } + padding: 0; + font-family: "Ubuntu", sans-serif; } a { text-decoration: none; - color: inherit; } + color: #3b5998; } + +img { + border: none; } .clearfix:after { content: "."; diff --git a/public/assets/application-37cb32f627581ac8bac91345987e7f10.css.gz b/public/assets/application-37cb32f627581ac8bac91345987e7f10.css.gz new file mode 100644 index 0000000000000000000000000000000000000000..4f942258a8fe27f6f26b080323d1a58e2ffe2f54 GIT binary patch literal 725 zcmV;`0xJCEsUWQ0>XMi%!ja%8<&usklP)E@o`iAYr~8Np<$EBLkqucVBeMbd8A=mEvK;AJCQo2Z%%wAF1r!SaAQ;kM^dABn{WbUtZ6Pf!~xsMKLTs#x$DXlWXG%! zdh-RrW%kxM;gO&q_=dtyMCp27XZDtf>6|_w!>!E$ z1$RPZN>E!V5$q;4pc*BHV<9%ylr0NG#1Ropo{&*Z?W4p}XJ)AJbQ{{$p&iDL8MbVA zn7XU_9+$4MEZu13kOFtw$E_XUdMDeU^GVsPUh@;v?Xtc~cOx<9sYeB>XGnRrhIwWCsKC(~g^6hQq zcQj5mxArDqv)HR6)@?#F2=}}YDKsFytMERglc`h^j_tpL&l25)#e33LT_pMs<+SaS H-V6W$b}ntZ literal 0 HcmV?d00001 diff --git a/web/public/assets/application-1b8e9e39ac5613519703a2e42949522a.js b/public/assets/application-47a9a60feaec5625a9c66b1c985a1179.js similarity index 95% rename from web/public/assets/application-1b8e9e39ac5613519703a2e42949522a.js rename to public/assets/application-47a9a60feaec5625a9c66b1c985a1179.js index 6c1ee62..a6f3663 100644 --- a/web/public/assets/application-1b8e9e39ac5613519703a2e42949522a.js +++ b/public/assets/application-47a9a60feaec5625a9c66b1c985a1179.js @@ -17,6 +17,11 @@ +}).call(this); +(function() { + + + }).call(this); // This is a manifest file that'll be compiled into application.js, which will include all the files // listed below. diff --git a/web/public/assets/application-1b8e9e39ac5613519703a2e42949522a.js.gz b/public/assets/application-47a9a60feaec5625a9c66b1c985a1179.js.gz similarity index 77% rename from web/public/assets/application-1b8e9e39ac5613519703a2e42949522a.js.gz rename to public/assets/application-47a9a60feaec5625a9c66b1c985a1179.js.gz index 572a9d1d42773d63a2730fd7f033fc7365ed92cb..a70851ae872b88c5697c4cda131ca38946dbed7b 100644 GIT binary patch delta 34 qcmbQmJd2rIzMF%ATihy;iTUV6ZXL$Y8!e(3Iec2{M4mG-FaQ9Ps|dpY delta 34 qcmbQmJd2rIzMF%gAkH|DiFxZpZXL$Q8!e(3Ii82b%{b1)zyJWIVhQ*F diff --git a/public/assets/bird_gray_16-93f51980875017e26744056b62aaac22.png b/public/assets/bird_gray_16-93f51980875017e26744056b62aaac22.png new file mode 100644 index 0000000000000000000000000000000000000000..8cf5afa6e34999512091ef78ce6edfe27e4bffe1 GIT binary patch literal 1106 zcmaJ=OK1~87@nG_wW8F5#fs>#iYK#=bdx4)W1D6h8*yt$qxK@W*_|e9-JR|3)NJde zz7C2)@gNEws+3YZh#+2kV8I@IK~eOe=s^@cYN6mkMQ3YMJs1~eXXfYszW?>j>1_AT zRdws@0065pU2=}@tLa)c*+W=yq+a!A#O1|FeS z00LW#d@t!$c1s#IS=IMpJ=3OW09xBTTh;mzfdy1FtOWD<&V2?NdV<*>QFz5pp_0)x z?4X|E?z}eKuf=tyZ3k@iBuZc+qC(F+Y`Kz`VCH!xdiKp61Ls{xe}eg)RIieSDeNE^ zVfm28M+F!aSwZCEVtgA6^8(KaVUBMJ3A_|(k$3?vd<>1|=zUU7PA|lww**rn#FjX& zTrRWaW)?d|PKd|j93SSw;Slu*xkDCFy^!T@t}w{R)f~en2DYHjs21=bNia0i-zAv# zBCX{vw23y1^HiG?Sl%zG;;1P9cQwsLZ_1*`wTwp7LXVlZtQSw@a=1nFr9n{d8p z$*7)-Se0)9t5?q@QWeY5WH^7ce~r3gqWbZVi^8RsMd>4p>fNEjp1HL#NFT*?Mo#9v z*M;vtf3`h%b+fqi?74Go{8-IsY;+eW)c*jJeKq;B$JSgMNQ~ZFv*p;tZ0l&ay+H!g zb?t8+2G@d1;Z2kFj;As-MismD|A literal 0 HcmV?d00001 diff --git a/public/assets/manifest-0b26a376c9cfe81af432b634628ee75d.json b/public/assets/manifest-0b26a376c9cfe81af432b634628ee75d.json new file mode 100644 index 0000000..8aabeda --- /dev/null +++ b/public/assets/manifest-0b26a376c9cfe81af432b634628ee75d.json @@ -0,0 +1 @@ +{"files":{"bird_gray_16-93f51980875017e26744056b62aaac22.png":{"logical_path":"bird_gray_16.png","mtime":"2013-03-09T14:41:39+09:00","size":1106,"digest":"93f51980875017e26744056b62aaac22"},"rails-bc7d436ef8afbf0f88829742a43ba3a4.png":{"logical_path":"rails.png","mtime":"2013-02-25T21:20:52+09:00","size":6646,"digest":"bc7d436ef8afbf0f88829742a43ba3a4"},"application-47a9a60feaec5625a9c66b1c985a1179.js":{"logical_path":"application.js","mtime":"2013-03-09T01:51:23+09:00","size":743,"digest":"47a9a60feaec5625a9c66b1c985a1179"},"application-37cb32f627581ac8bac91345987e7f10.css":{"logical_path":"application.css","mtime":"2013-03-09T15:10:20+09:00","size":3294,"digest":"37cb32f627581ac8bac91345987e7f10"}},"assets":{"bird_gray_16.png":"bird_gray_16-93f51980875017e26744056b62aaac22.png","rails.png":"rails-bc7d436ef8afbf0f88829742a43ba3a4.png","application.js":"application-47a9a60feaec5625a9c66b1c985a1179.js","application.css":"application-37cb32f627581ac8bac91345987e7f10.css"}} \ No newline at end of file diff --git a/web/public/assets/rails-bc7d436ef8afbf0f88829742a43ba3a4.png b/public/assets/rails-bc7d436ef8afbf0f88829742a43ba3a4.png similarity index 100% rename from web/public/assets/rails-bc7d436ef8afbf0f88829742a43ba3a4.png rename to public/assets/rails-bc7d436ef8afbf0f88829742a43ba3a4.png diff --git a/web/public/favicon.ico b/public/favicon.ico similarity index 100% rename from web/public/favicon.ico rename to public/favicon.ico diff --git a/web/script/rails b/script/rails similarity index 100% rename from web/script/rails rename to script/rails diff --git a/start.rb b/start.rb deleted file mode 100755 index 3845c79..0000000 --- a/start.rb +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env ruby - -require ::File.expand_path('../web/config/application', __FILE__) -Rails.application.require_environment! - -require ::File.expand_path('../worker/receiver', __FILE__) -Receiver::Worker.new.start - diff --git a/test/controllers/errors_controller_test.rb b/test/controllers/errors_controller_test.rb new file mode 100644 index 0000000..dcd460a --- /dev/null +++ b/test/controllers/errors_controller_test.rb @@ -0,0 +1,14 @@ +require 'test_helper' + +class ErrorsControllerTest < ActionController::TestCase + test "should get error_404" do + get :error_404 + assert_response :success + end + + test "should get error_500" do + get :error_500 + assert_response :success + end + +end diff --git a/test/helpers/errors_helper_test.rb b/test/helpers/errors_helper_test.rb new file mode 100644 index 0000000..2b0c217 --- /dev/null +++ b/test/helpers/errors_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class ErrorsHelperTest < ActionView::TestCase +end diff --git a/web/Gemfile b/web/Gemfile deleted file mode 100644 index 7530826..0000000 --- a/web/Gemfile +++ /dev/null @@ -1,50 +0,0 @@ -ruby '1.9.3' -source 'https://rubygems.org' - -gem 'rails', '4.0.0.beta1' - -gem 'thin' - -# Bundle edge Rails instead: -# gem 'rails', :git => 'git://github.com/rails/rails.git' - -gem 'mysql2' -gem 'haml-rails' - -# Gems used only for assets and not required -# in production environments by default. -group :assets do - gem 'sass-rails', '~> 4.0.0.beta1' - gem 'coffee-rails', '~> 4.0.0.beta1' - - # See https://github.com/sstephenson/execjs#readme for more supported runtimes - gem 'therubyracer', :platforms => :ruby - - gem 'uglifier', '>= 1.0.3' -end - -group :development do - gem 'sqlite3' -end - -gem 'yajl-ruby', :require => "yajl" -gem 'rails_config' -gem 'omniauth-twitter', :github => "re4k/omniauth-twitter" -gem 'em-twitter' -gem 'twitter' -gem 'will_paginate', :github => 're4k/will_paginate' - -# To use ActiveModel has_secure_password -# gem 'bcrypt-ruby', '~> 3.0.0' - -# To use Jbuilder templates for JSON -# gem 'jbuilder' - -# Use unicorn as the app server -gem 'unicorn' - -# Deploy with Capistrano -# gem 'capistrano' - -# To use debugger -# gem 'debugger' diff --git a/web/Gemfile.lock b/web/Gemfile.lock deleted file mode 100644 index 07f3817..0000000 --- a/web/Gemfile.lock +++ /dev/null @@ -1,182 +0,0 @@ -GIT - remote: git://github.com/re4k/omniauth-twitter.git - revision: 313df7eb05e78477cf3eb06bced3c9b64957840f - specs: - omniauth-twitter (0.0.14) - multi_json (~> 1.3) - omniauth-oauth (~> 1.0) - -GIT - remote: git://github.com/re4k/will_paginate.git - revision: fcbbd91ced44aaabb1f369875ee9f4f651bc74fb - specs: - will_paginate (3.0.4) - -GEM - remote: https://rubygems.org/ - specs: - actionmailer (4.0.0.beta1) - actionpack (= 4.0.0.beta1) - mail (~> 2.5.3) - actionpack (4.0.0.beta1) - activesupport (= 4.0.0.beta1) - builder (~> 3.1.0) - erubis (~> 2.7.0) - rack (~> 1.5.2) - rack-test (~> 0.6.2) - activemodel (4.0.0.beta1) - activesupport (= 4.0.0.beta1) - builder (~> 3.1.0) - activerecord (4.0.0.beta1) - activemodel (= 4.0.0.beta1) - activerecord-deprecated_finders (~> 0.0.3) - activesupport (= 4.0.0.beta1) - arel (~> 4.0.0.beta1) - activerecord-deprecated_finders (0.0.3) - activesupport (4.0.0.beta1) - i18n (~> 0.6.2) - minitest (~> 4.2) - multi_json (~> 1.3) - thread_safe (~> 0.1) - tzinfo (~> 0.3.33) - arel (4.0.0.beta1) - atomic (1.0.1) - builder (3.1.4) - coffee-rails (4.0.0.beta1) - coffee-script (>= 2.2.0) - railties (>= 4.0.0.beta, < 5.0) - coffee-script (2.2.0) - coffee-script-source - execjs - coffee-script-source (1.6.1) - daemons (1.1.9) - em-twitter (0.2.1) - eventmachine (~> 1.0) - http_parser.rb (~> 0.5) - simple_oauth (~> 0.1) - erubis (2.7.0) - eventmachine (1.0.1) - execjs (1.4.0) - multi_json (~> 1.0) - faraday (0.8.6) - multipart-post (~> 1.1) - haml (4.0.0) - tilt - haml-rails (0.4) - actionpack (>= 3.1, < 4.1) - activesupport (>= 3.1, < 4.1) - haml (>= 3.1, < 4.1) - railties (>= 3.1, < 4.1) - hashie (1.2.0) - hike (1.2.1) - http_parser.rb (0.5.3) - i18n (0.6.4) - json (1.7.7) - kgio (2.8.0) - libv8 (3.11.8.13) - mail (2.5.3) - i18n (>= 0.4.0) - mime-types (~> 1.16) - treetop (~> 1.4.8) - mime-types (1.21) - minitest (4.6.2) - multi_json (1.6.1) - multipart-post (1.2.0) - mysql2 (0.3.11) - oauth (0.4.7) - omniauth (1.1.3) - hashie (~> 1.2) - rack - omniauth-oauth (1.0.1) - oauth - omniauth (~> 1.0) - polyglot (0.3.3) - rack (1.5.2) - rack-test (0.6.2) - rack (>= 1.0) - rails (4.0.0.beta1) - actionmailer (= 4.0.0.beta1) - actionpack (= 4.0.0.beta1) - activerecord (= 4.0.0.beta1) - activesupport (= 4.0.0.beta1) - bundler (>= 1.3.0, < 2.0) - railties (= 4.0.0.beta1) - sprockets-rails (~> 2.0.0.rc3) - rails_config (0.3.2) - activesupport (>= 3.0) - railties (4.0.0.beta1) - actionpack (= 4.0.0.beta1) - activesupport (= 4.0.0.beta1) - rake (>= 0.8.7) - rdoc (~> 3.4) - thor (>= 0.17.0, < 2.0) - raindrops (0.10.0) - rake (10.0.3) - rdoc (3.12.2) - json (~> 1.4) - ref (1.0.2) - sass (3.2.6) - sass-rails (4.0.0.beta1) - railties (>= 4.0.0.beta, < 5.0) - sass (>= 3.1.10) - sprockets-rails (~> 2.0.0.rc0) - tilt (~> 1.3) - simple_oauth (0.2.0) - sprockets (2.9.0) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.0.0.rc3) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (~> 2.8) - sqlite3 (1.3.7) - therubyracer (0.11.4) - libv8 (~> 3.11.8.12) - ref - thin (1.5.0) - daemons (>= 1.0.9) - eventmachine (>= 0.12.6) - rack (>= 1.0.0) - thor (0.17.0) - thread_safe (0.1.0) - atomic - tilt (1.3.4) - treetop (1.4.12) - polyglot - polyglot (>= 0.3.1) - twitter (4.5.0) - faraday (~> 0.8, < 0.10) - multi_json (~> 1.0) - simple_oauth (~> 0.2) - tzinfo (0.3.36) - uglifier (1.3.0) - execjs (>= 0.3.0) - multi_json (~> 1.0, >= 1.0.2) - unicorn (4.6.2) - kgio (~> 2.6) - rack - raindrops (~> 0.7) - yajl-ruby (1.1.0) - -PLATFORMS - ruby - -DEPENDENCIES - coffee-rails (~> 4.0.0.beta1) - em-twitter - haml-rails - mysql2 - omniauth-twitter! - rails (= 4.0.0.beta1) - rails_config - sass-rails (~> 4.0.0.beta1) - sqlite3 - therubyracer - thin - twitter - uglifier (>= 1.0.3) - unicorn - will_paginate! - yajl-ruby diff --git a/web/README.rdoc b/web/README.rdoc deleted file mode 100644 index 7c36f23..0000000 --- a/web/README.rdoc +++ /dev/null @@ -1,261 +0,0 @@ -== Welcome to Rails - -Rails is a web-application framework that includes everything needed to create -database-backed web applications according to the Model-View-Control pattern. - -This pattern splits the view (also called the presentation) into "dumb" -templates that are primarily responsible for inserting pre-built data in between -HTML tags. The model contains the "smart" domain objects (such as Account, -Product, Person, Post) that holds all the business logic and knows how to -persist themselves to a database. The controller handles the incoming requests -(such as Save New Account, Update Product, Show Post) by manipulating the model -and directing data to the view. - -In Rails, the model is handled by what's called an object-relational mapping -layer entitled Active Record. This layer allows you to present the data from -database rows as objects and embellish these data objects with business logic -methods. You can read more about Active Record in -link:files/vendor/rails/activerecord/README.html. - -The controller and view are handled by the Action Pack, which handles both -layers by its two parts: Action View and Action Controller. These two layers -are bundled in a single package due to their heavy interdependence. This is -unlike the relationship between the Active Record and Action Pack that is much -more separate. Each of these packages can be used independently outside of -Rails. You can read more about Action Pack in -link:files/vendor/rails/actionpack/README.html. - - -== Getting Started - -1. At the command prompt, create a new Rails application: - rails new myapp (where myapp is the application name) - -2. Change directory to myapp and start the web server: - cd myapp; rails server (run with --help for options) - -3. Go to http://localhost:3000/ and you'll see: - "Welcome aboard: You're riding Ruby on Rails!" - -4. Follow the guidelines to start developing your application. You can find -the following resources handy: - -* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html -* Ruby on Rails Tutorial Book: http://www.railstutorial.org/ - - -== Debugging Rails - -Sometimes your application goes wrong. Fortunately there are a lot of tools that -will help you debug it and get it back on the rails. - -First area to check is the application log files. Have "tail -f" commands -running on the server.log and development.log. Rails will automatically display -debugging and runtime information to these files. Debugging info will also be -shown in the browser on requests from 127.0.0.1. - -You can also log your own messages directly into the log file from your code -using the Ruby logger class from inside your controllers. Example: - - class WeblogController < ActionController::Base - def destroy - @weblog = Weblog.find(params[:id]) - @weblog.destroy - logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!") - end - end - -The result will be a message in your log file along the lines of: - - Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1! - -More information on how to use the logger is at http://www.ruby-doc.org/core/ - -Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are -several books available online as well: - -* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe) -* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide) - -These two books will bring you up to speed on the Ruby language and also on -programming in general. - - -== Debugger - -Debugger support is available through the debugger command when you start your -Mongrel or WEBrick server with --debugger. This means that you can break out of -execution at any point in the code, investigate and change the model, and then, -resume execution! You need to install ruby-debug to run the server in debugging -mode. With gems, use sudo gem install ruby-debug. Example: - - class WeblogController < ActionController::Base - def index - @posts = Post.all - debugger - end - end - -So the controller will accept the action, run the first line, then present you -with a IRB prompt in the server window. Here you can do things like: - - >> @posts.inspect - => "[#nil, "body"=>nil, "id"=>"1"}>, - #"Rails", "body"=>"Only ten..", "id"=>"2"}>]" - >> @posts.first.title = "hello from a debugger" - => "hello from a debugger" - -...and even better, you can examine how your runtime objects actually work: - - >> f = @posts.first - => #nil, "body"=>nil, "id"=>"1"}> - >> f. - Display all 152 possibilities? (y or n) - -Finally, when you're ready to resume execution, you can enter "cont". - - -== Console - -The console is a Ruby shell, which allows you to interact with your -application's domain model. Here you'll have all parts of the application -configured, just like it is when the application is running. You can inspect -domain models, change values, and save to the database. Starting the script -without arguments will launch it in the development environment. - -To start the console, run rails console from the application -directory. - -Options: - -* Passing the -s, --sandbox argument will rollback any modifications - made to the database. -* Passing an environment name as an argument will load the corresponding - environment. Example: rails console production. - -To reload your controllers and models after launching the console run -reload! - -More information about irb can be found at: -link:http://www.rubycentral.org/pickaxe/irb.html - - -== dbconsole - -You can go to the command line of your database directly through rails -dbconsole. You would be connected to the database with the credentials -defined in database.yml. Starting the script without arguments will connect you -to the development database. Passing an argument will connect you to a different -database, like rails dbconsole production. Currently works for MySQL, -PostgreSQL and SQLite 3. - -== Description of Contents - -The default directory structure of a generated Ruby on Rails application: - - |-- app - | |-- assets - | |-- images - | |-- javascripts - | `-- stylesheets - | |-- controllers - | |-- helpers - | |-- mailers - | |-- models - | `-- views - | `-- layouts - |-- config - | |-- environments - | |-- initializers - | `-- locales - |-- db - |-- doc - |-- lib - | `-- tasks - |-- log - |-- public - |-- script - |-- test - | |-- fixtures - | |-- functional - | |-- integration - | |-- performance - | `-- unit - |-- tmp - | |-- cache - | |-- pids - | |-- sessions - | `-- sockets - `-- vendor - |-- assets - `-- stylesheets - `-- plugins - -app - Holds all the code that's specific to this particular application. - -app/assets - Contains subdirectories for images, stylesheets, and JavaScript files. - -app/controllers - Holds controllers that should be named like weblogs_controller.rb for - automated URL mapping. All controllers should descend from - ApplicationController which itself descends from ActionController::Base. - -app/models - Holds models that should be named like post.rb. Models descend from - ActiveRecord::Base by default. - -app/views - Holds the template files for the view that should be named like - weblogs/index.html.erb for the WeblogsController#index action. All views use - eRuby syntax by default. - -app/views/layouts - Holds the template files for layouts to be used with views. This models the - common header/footer method of wrapping views. In your views, define a layout - using the layout :default and create a file named default.html.erb. - Inside default.html.erb, call <% yield %> to render the view using this - layout. - -app/helpers - Holds view helpers that should be named like weblogs_helper.rb. These are - generated for you automatically when using generators for controllers. - Helpers can be used to wrap functionality for your views into methods. - -config - Configuration files for the Rails environment, the routing map, the database, - and other dependencies. - -db - Contains the database schema in schema.rb. db/migrate contains all the - sequence of Migrations for your schema. - -doc - This directory is where your application documentation will be stored when - generated using rake doc:app - -lib - Application specific libraries. Basically, any kind of custom code that - doesn't belong under controllers, models, or helpers. This directory is in - the load path. - -public - The directory available for the web server. Also contains the dispatchers and the - default HTML files. This should be set as the DOCUMENT_ROOT of your web - server. - -script - Helper scripts for automation and generation. - -test - Unit and functional tests along with fixtures. When using the rails generate - command, template test files will be generated for you and placed in this - directory. - -vendor - External libraries that the application depends on. Also includes the plugins - subdirectory. If the app has frozen rails, those gems also go here, under - vendor/rails/. This directory is in the load path. diff --git a/web/app/controllers/i_controller.rb b/web/app/controllers/i_controller.rb deleted file mode 100644 index 5d44bc1..0000000 --- a/web/app/controllers/i_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -class IController < ApplicationController - def show - id = params[:id].to_i - @item = Tweet.find(id) - @title = "Tweet" - end -end diff --git a/web/app/mailers/.gitkeep b/web/app/mailers/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/web/app/models/.gitkeep b/web/app/models/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/web/app/views/main/index.haml b/web/app/views/main/index.haml deleted file mode 100644 index 2f87ddb..0000000 --- a/web/app/views/main/index.haml +++ /dev/null @@ -1,13 +0,0 @@ -%strong (´へεへ`*) < トップページだよ〜〜 -%strong まだ開発途中段階のものであり、いつデータベースをクリアするかわかりませんがとりあえず動いています。ワーカープロセスが1つしかないため、登録後接続まで最大30分かかります。 -%strong 動作のテスト中ですので、途中で登録をうちきったりあまりにふぁぼられ・ふぁぼりが多いユーザーの登録を削除する可能性もあります。 -%strong 学校の方のテスト期間中なんで1週間くらい放置します_(:3 」∠ )_ -%div - URLとかについて - %div - best: /re4k/ - %div - recent: /re4k/recent -%div - = link_to "@re4k", "https://twitter.com/re4k" - diff --git a/web/app/views/users/my.haml b/web/app/views/users/my.haml deleted file mode 100644 index 4e54081..0000000 --- a/web/app/views/users/my.haml +++ /dev/null @@ -1,2 +0,0 @@ -%div.items - = render :partial => "shared/tweet", :collection => @items, :as => :item diff --git a/web/config/database.yml b/web/config/database.yml deleted file mode 100644 index a8c0f51..0000000 --- a/web/config/database.yml +++ /dev/null @@ -1,33 +0,0 @@ -<% -require "json" - -environment = File.exists?("/home/dotcloud/environment.json") ? - JSON.parse(File.read("/home/dotcloud/environment.json")) : - {} -%> -development: - adapter: sqlite3 - database: db/development.sqlite3 - pool: 5 - timeout: 5000 - -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - adapter: sqlite3 - database: db/test.sqlite3 - pool: 5 - timeout: 5000 - -production: - adapter: mysql2 - encoding: utf8 - reconnect: true - database: production - pool: 5 - username: <%= environment["DOTCLOUD_DB_MYSQL_LOGIN"] %> - password: <%= environment["DOTCLOUD_DB_MYSQL_PASSWORD"] %> - host: <%= environment["DOTCLOUD_DB_MYSQL_HOST"] %> - port: <%= environment["DOTCLOUD_DB_MYSQL_PORT"] %> - diff --git a/web/config/routes.rb b/web/config/routes.rb deleted file mode 100644 index abb15c3..0000000 --- a/web/config/routes.rb +++ /dev/null @@ -1,24 +0,0 @@ -Aclog::Application.routes.draw do - constraints = { - :id => /[0-9]+/, - :screen_name => /[a-zA-Z0-9_]{1,20}/, - :page => /[0-9]+/, - } - - paging_defaults = { - :page => "1" - } - - root :to => "main#index" - get "i/callback" => "sessions#callback" - get "i/logout" => "sessions#destroy" - - get "i/:id" => "i#show", :constraints => constraints - get ":screen_name/status(es)/:id" => "i#show", :constraints => constraints - - get ":screen_name(/:page)" => "users#best", :constraints => constraints, :defaults => paging_defaults - get ":screen_name/my(/:page)" => "users#my", :constraints => constraints, :defaults => paging_defaults - get ":screen_name/timeline(/:page)" => "users#timeline", :constraints => constraints, :defaults => paging_defaults - get ":screen_name/recent(/:page)" => "users#recent", :constraints => constraints, :defaults => paging_defaults - get ":screen_name/info(/:page)" => "users#info", :constraints => constraints, :defaults => paging_defaults -end diff --git a/web/config/settings.yml b/web/config/settings.yml deleted file mode 100644 index d4c904f..0000000 --- a/web/config/settings.yml +++ /dev/null @@ -1,4 +0,0 @@ -consumer_key: <%= ENV["CONSUMER_KEY"] %> -consumer_secret: <%= ENV["CONSUMER_SECRET"] %> -worker_port: 46607 -page_per: 10 diff --git a/web/lib/assets/.gitkeep b/web/lib/assets/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/web/lib/tasks/.gitkeep b/web/lib/tasks/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/web/log/.gitkeep b/web/log/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/web/public/assets/application-862b4db892f94edcb21b7275b0a049b0.css.gz b/web/public/assets/application-862b4db892f94edcb21b7275b0a049b0.css.gz deleted file mode 100644 index 7850cc21f8646a1d83811d8199204078691e73ec..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 650 zcmV;50(Jc#iwFR{r8iLm1Ep5mZlf>|ea}}|?b~XxNH%FB@-dNP2C!;uWF{f$YX5zW zAp{7aam$N^FXx<@v5!p!LSB-;3qmRpV-}Ik`>Hta?0?QoDpW+4o8nBurde+782M*M zX|vEZZuxjYGi@}HVg-Qhd_wdIOd@p^kxaxfs9oECVEiLB`l#ZFRGD4b4QLaCu@sh} z)KbLcl`r{*ABGcxHkPFm(he0Yj)h7aeOGnU`Y1awWTw;ECFd<{a?^ZPI>U%aNbrU? zk0|oAhuYz;w|!hfG7xEoZU4Mf*X+4g2nzR!IQQ`T0>`0*x1KB8cH_tPB-8r+PapRw zWO^*Y3^LV~FC=a!ZiX34?82aG1373J_XoL_+U}ayH~00Wc!;5juXxnqMu@lwFv=&Gl%@&3RfqRt~Sd*H_?RH#Hxx#G}mpHA&GKIQg4!QZ~C z>i0@|>YFTxfosE1Xw~L-(Va%2GBCnrVnLn1*_{`$1lwms8*4;f k=u5rqBua4*QsAZk_`EmSYhX@U-#0DMe_(#n?L7+s05zFMhyVZp diff --git a/web/public/assets/application-c11f88ddf5d2294cfc1779fcb0be52cf.css b/web/public/assets/application-c11f88ddf5d2294cfc1779fcb0be52cf.css deleted file mode 100644 index b7c7900..0000000 --- a/web/public/assets/application-c11f88ddf5d2294cfc1779fcb0be52cf.css +++ /dev/null @@ -1,84 +0,0 @@ -.items { - width: 572px; - margin: 15px 0 15px 18px; } - .items .item { - margin: 15px 0; } - .items .item .tweet { - overflow: hidden; - background: white; - border: 1px solid #c1c5cb; - border-width: 1px 0; - padding: 15px; } - .items .item .tweet .avatar { - width: 60px; - float: left; } - .items .item .tweet .avatar img { - width: 48px; - height: 48px; } - .items .item .tweet .tweet_content_fix { - float: left; - width: 1px; - height: 85px; } - .items .item .tweet .tweet_content { - float: left; - width: 473px; } - .items .item .tweet .tweet_content .user { - font-weight: bold; - color: #666666; } - .items .item .tweet .tweet_content .user .name { - font-size: 14px; } - .items .item .tweet .tweet_content .user .screen_name { - font-size: 12px; } - .items .item .tweet .tweet_content .text { - font-size: 18px; - line-height: 25px; - padding: 0 5px 15px; - word-wrap: break-word; } - .items .item .tweet .tweet_content .meta { - color: #666666; - font-size: 12px; } - .items .item .tweet .tweet_content .meta .created_at { - display: block; - float: left; } - .items .item .tweet .tweet_content .meta .source { - display: block; - float: right; } - .items .item .stats { - clear: both; - padding: 15px; } - .items .item .stats .type_row .info { - width: 60px; - float: left; } - .items .item .stats .type_row .info .count, - .items .item .stats .type_row .info .type { - color: #666666; - display: block; } - .items .item .stats .type_row .info .count { - font-weight: bold; - font-size: 14px; } - .items .item .stats .type_row .info .type { - font-size: 10px; } - .items .item .stats .type_row ul.users_row { - list-style: none; - float: left; } - .items .item .stats .type_row ul.users_row li { - float: left; } - .items .item .stats .type_row ul.users_row li img { - width: 48px; - height: 48px; } - -* { - vertical-align: baseline; - margin: 0; - padding: 0; } - -a { - text-decoration: none; - color: inherit; } - -.clearfix:after { - content: "."; - visibility: hidden; - display: block; - height: 0; - clear: both; } diff --git a/web/public/assets/application-c11f88ddf5d2294cfc1779fcb0be52cf.css.gz b/web/public/assets/application-c11f88ddf5d2294cfc1779fcb0be52cf.css.gz deleted file mode 100644 index 5c1d999ff82cf743d2c7c5ff3965d5eb0aa044dd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 598 zcmV-c0;&BUiwFSpDmPIA1Fcq3liDBAdxi&9MSoZtAUDyRG5sr@hnh{b-fkjHz@5}PC_5Vj^bE#9ZSeF+vZ-&Lj+sJQk zrHx}4g8R^+SvFWmu>!z$Jt5`{HdCfbNg;&*y=~|Bj307qPFkd-D!gZBFjj!|6rRBu zB?Woq3%=(2{(_{9Wf6q5rjiLEb>8T^se7)EvNJW=ecJ(nQq0|TF%2!rWSyuYoTVRKzo|r232*`S32irCq zm6i!y)Tf;xh#kX0+J$tbVpkuHGW@XZZ^`q*p2F+Q$#R&^Y3t2--a8#KbR8mBz-(Oy zSWN104GP6;2|H^lKdm$KUpn1$WXgRX$M4g8>i?1FWRTM@sT<#BKIjHt3oHhlkKeVE z3Vp?epF5tC&ZFT~c{pt}{NoPxSd{DwA6FxvK@Km(zg~%tm*VVO@bqs8l$@!ADVh7{ z$DTQ;8(sW{36Fq#gA3kGBdXhHB7hsqP#S$tTYKW9F2KqV;*5rx^H*%jGHfrWw(L{# kLSJgPvvhJVmBefOsCg{>TQEUcT+5#552npr)RhSU0B-##k^lez diff --git a/web/public/assets/manifest-6b01fb44e2a668d3c0196abd4bdfbb15.json b/web/public/assets/manifest-6b01fb44e2a668d3c0196abd4bdfbb15.json deleted file mode 100644 index 5967163..0000000 --- a/web/public/assets/manifest-6b01fb44e2a668d3c0196abd4bdfbb15.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{"rails-bc7d436ef8afbf0f88829742a43ba3a4.png":{"logical_path":"rails.png","mtime":"2013-02-25T21:20:52+09:00","size":6646,"digest":"bc7d436ef8afbf0f88829742a43ba3a4"},"application-1b8e9e39ac5613519703a2e42949522a.js":{"logical_path":"application.js","mtime":"2013-03-03T23:30:08+09:00","size":711,"digest":"1b8e9e39ac5613519703a2e42949522a"},"application-c11f88ddf5d2294cfc1779fcb0be52cf.css":{"logical_path":"application.css","mtime":"2013-03-06T20:39:32+09:00","size":2453,"digest":"c11f88ddf5d2294cfc1779fcb0be52cf"},"application-862b4db892f94edcb21b7275b0a049b0.css":{"logical_path":"application.css","mtime":"2013-03-07T05:23:25+09:00","size":2877,"digest":"862b4db892f94edcb21b7275b0a049b0"}},"assets":{"rails.png":"rails-bc7d436ef8afbf0f88829742a43ba3a4.png","application.js":"application-1b8e9e39ac5613519703a2e42949522a.js","application.css":"application-862b4db892f94edcb21b7275b0a049b0.css"}} \ No newline at end of file diff --git a/web/vendor/assets/javascripts/.gitkeep b/web/vendor/assets/javascripts/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/web/vendor/assets/stylesheets/.gitkeep b/web/vendor/assets/stylesheets/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/web/vendor/plugins/.gitkeep b/web/vendor/plugins/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/worker.sh b/worker.sh new file mode 100755 index 0000000..837ab11 --- /dev/null +++ b/worker.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +bundle exec rails runner Receiver::Worker.new.start + + diff --git a/worker/receiver.rb b/worker/receiver.rb deleted file mode 100644 index 06680a7..0000000 --- a/worker/receiver.rb +++ /dev/null @@ -1,6 +0,0 @@ -module Receiver - require ::File.expand_path("../receiver/logger", __FILE__) - require ::File.expand_path("../receiver/worker", __FILE__) - - # monyo -end diff --git a/worker/receiver/logger.rb b/worker/receiver/logger.rb deleted file mode 100644 index 45fe5ed..0000000 --- a/worker/receiver/logger.rb +++ /dev/null @@ -1,28 +0,0 @@ -class Receiver::Logger - include Singleton - - def debug(msg) - log(@out, "DEBUG", msg) - end - - def info(msg) - log(@out, "INFO", msg) - end - - def warn(msg) - log(@err, "WARN", msg) - end - - def error(msg) - log(@err, "ERROR", msg) - end - - def log(out, type, msg) - out.puts Time.now.utc.iso8601(3) + " " + type + ": " + msg.to_s - end - - def initialize - @out = STDOUT - @err = STDERR - end -end