gimdb 0.0.6 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,10 @@
1
- #require "#{$GIMDB_PATH}/src/model"
2
-
3
-
4
1
  module GtkGimdb
5
2
 
6
3
  class ManagerBox < Gtk::HBox
7
4
  include GetText
8
5
 
9
-
10
6
  def initialize(klass, field)
11
- bindtextdomain($DOMAIN, $LOCALEDIR, nil, 'UTF-8')
7
+ bindtextdomain($DOMAIN, :path => $LOCALEDIR)
12
8
  super()
13
9
  @comboboxentry = Gtk::ComboBoxEntry.new
14
10
  @image_add = Gtk::Image.new(Gtk::Stock::ADD, Gtk::IconSize::BUTTON)
@@ -1,16 +1,15 @@
1
- require 'rubygems'
2
1
  require 'active_record'
3
2
  require 'etc'
4
3
 
5
4
 
6
- $GIMDB_LOCAL_PATH = "#{Etc.getpwuid.dir}/.gimdb"
7
- Dir.mkdir($GIMDB_LOCAL_PATH) unless File.exist?($GIMDB_LOCAL_PATH)
8
- Dir.mkdir("#{$GIMDB_LOCAL_PATH}/posters") unless File.exist?("#{$GIMDB_LOCAL_PATH}/posters")
5
+ $APP_LOCAL_PATH = "#{Etc.getpwuid.dir}/.gimdb"
6
+ Dir.mkdir($APP_LOCAL_PATH) unless File.exist?($APP_LOCAL_PATH)
7
+ Dir.mkdir("#{$APP_LOCAL_PATH}/posters") unless File.exist?("#{$APP_LOCAL_PATH}/posters")
9
8
 
10
9
 
11
10
  ActiveRecord::Base.establish_connection(
12
11
  :adapter => "sqlite3",
13
- :database => "#{$GIMDB_LOCAL_PATH}/db.sqlite3"
12
+ :database => "#{$APP_LOCAL_PATH}/db.sqlite3"
14
13
  )
15
14
 
16
15
 
@@ -32,7 +31,7 @@ if(!ActiveRecord::Base.connection.tables.include?('movies') ||
32
31
  t.float :runtime
33
32
  t.datetime :updated_at, :null => false, :default => Time.now
34
33
  end
35
-
34
+
36
35
  create_table :users do |t|
37
36
  t.string :name, :unique => true, :null => :false
38
37
  t.integer :selected, :limit => 1, :default => 0
@@ -63,7 +62,7 @@ class Movie < ActiveRecord::Base
63
62
  def get_users(what = :to_see)
64
63
  code = Movie.get_code(what)
65
64
  unless code.nil?
66
- pops = Popular.find(:all, :conditions => "movie_id = #{self.id} AND kind = #{code}")
65
+ pops = Popular.where("movie_id = ? AND kind = ?", self.id, code)
67
66
  return [] if pops.nil?
68
67
  return pops.collect{|pop| pop.user}
69
68
  else
@@ -93,7 +92,7 @@ class Movie < ActiveRecord::Base
93
92
  c += " AND title LIKE '%#{options[:title]}%'" if options[:title]
94
93
  if options[:release_data] && options[:release_data].include?(',')
95
94
  c += " AND year >= #{options[:release_data].split(',')[0]}"
96
- c += " AND year <= #{options[:release_data].split(',')[1]}"
95
+ c += " AND year <= #{options[:release_data].split(',')[1]}"
97
96
  end
98
97
  if options[:user_rating] && options[:user_rating].include?(',')
99
98
  c += " AND rating >= #{options[:user_rating].split(',')[0]}"
@@ -101,7 +100,7 @@ class Movie < ActiveRecord::Base
101
100
  end
102
101
  c += " AND genre LIKE '%#{options[:genre]}%'" if options[:genre]
103
102
  c = c[5..-1]
104
- @movies = Movie.find(:all, :conditions => c, :order => 'title ASC')#, :limit => 50)
103
+ @movies = Movie.where(c).order('title ASC')#.limit(50)
105
104
  return @movies[@start-1..@start+48]
106
105
  end
107
106
 
@@ -115,15 +114,15 @@ class Movie < ActiveRecord::Base
115
114
  users.each { |u| c += "populars.user_id = #{u.id} OR " }
116
115
  c = '(' + c[0..-5] + ') AND ' unless c.empty?
117
116
  c += "populars.kind = #{Movie.get_code(kind)}"
118
- Movie.find(:all, :joins => :populars, :conditions => c, :order => 'title ASC', :group => 'movies.id')
117
+ Movie.select('movies.*').where(c).joins(:populars).order('title ASC').group('movies.id')
119
118
  end
120
-
119
+
121
120
  def self.get_code(what)
122
121
  case what.to_sym
123
- when :to_see: 0
124
- when :seen: 1
125
- when :favourites: 2
126
- else nil
122
+ when :to_see then 0
123
+ when :seen then 1
124
+ when :favourites then 2
125
+ else nil
127
126
  end
128
127
  end
129
128
  end
@@ -135,3 +134,4 @@ class User < ActiveRecord::Base
135
134
  validates_presence_of :name
136
135
  validates_uniqueness_of :name
137
136
  end
137
+
@@ -1,7 +1,8 @@
1
1
  module GtkGimdb
2
2
 
3
- class MovieBox < Gtk::HBox
3
+ class MovieBox < Gtk::VBox
4
4
  include GetText
5
+ attr_reader :movie
5
6
 
6
7
 
7
8
  def initialize(movie, users = [])
@@ -10,6 +11,15 @@ module GtkGimdb
10
11
  @movie = movie
11
12
  @users = users
12
13
  setting_up
14
+ self.show_all
15
+ end
16
+
17
+ def has_poster?
18
+ @movie.image_path && File.exist?(@movie.image_path)
19
+ end
20
+
21
+ def set_poster
22
+ @img.file = @movie.image_path if has_poster?
13
23
  end
14
24
 
15
25
 
@@ -17,10 +27,8 @@ module GtkGimdb
17
27
 
18
28
 
19
29
  def setting_up
20
- img = Gtk::Image.new((@movie.image_path.nil? || !File.exists?(@movie.image_path)) ? "#{$GIMDB_PATH}/data/icons/no_poster.png" : @movie.image_path)
21
- img.set_tooltip_text("Code: #{@movie.code}")
22
- self.pack_start(img, false)
23
-
30
+ hbox = Gtk::HBox.new
31
+ hbox.spacing = 10
24
32
  vbox = Gtk::VBox.new
25
33
  vbox.spacing = 10
26
34
  hbox1 = Gtk::HBox.new
@@ -28,6 +36,11 @@ module GtkGimdb
28
36
  hbox2 = Gtk::HBox.new
29
37
  hbox2.spacing = 50
30
38
 
39
+ @img = Gtk::Image.new("#{$APP_PATH}/data/icons/no_poster.png")
40
+ set_poster
41
+ @img.set_tooltip_text("Code: #{@movie.code}")
42
+ hbox.pack_start(@img, false)
43
+
31
44
  title = Gtk::Label.new
32
45
  year = (@movie.year.nil? || @movie.year == 0) ? '' : "(#{@movie.year})"
33
46
  title.markup = "<a href='http://www.imdb.it/title/#{@movie.code}/'><span color='#000' underline='none' size='large' weight='ultrabold'>#{@movie.title}</span></a> #{year}"
@@ -54,7 +67,7 @@ module GtkGimdb
54
67
  vbox.pack_start(credit, false)
55
68
 
56
69
  genre = Gtk::Label.new
57
- genre.text = @movie.genre.nil? ? '' : _('Genres') + ': ' + @movie.genre.gsub('|', ' | ')
70
+ genre.text = @movie.genre.nil? ? '' : _('Genres') + ': ' + @movie.genre.gsub('|', ' | ')
58
71
  hbox2.pack_start(genre, false)
59
72
 
60
73
  runtime = Gtk::Label.new
@@ -68,12 +81,14 @@ module GtkGimdb
68
81
  vbox.pack_start(hbox2, false)
69
82
 
70
83
  vbox.pack_start(add_users_info, false) if @users.size > 0
71
-
72
- self.pack_start(vbox)
84
+
85
+ hbox.pack_start(vbox)
86
+
87
+ self.pack_start(hbox)
88
+ self.pack_start(Gtk::HSeparator.new, false)
73
89
  self.spacing = 10
74
90
  end
75
91
 
76
-
77
92
  def add_users_info
78
93
  table = Gtk::Table.new(@users.size + 1, 4)
79
94
  table.attach(Gtk::Label.new, 0,1, 0,1, Gtk::SHRINK)
@@ -90,7 +105,7 @@ module GtkGimdb
90
105
  return table
91
106
  end
92
107
 
93
-
108
+
94
109
  class UserCheckButton < Gtk::CheckButton
95
110
  def initialize(user, movie, what)
96
111
  super()
@@ -102,9 +117,10 @@ module GtkGimdb
102
117
  movie.remove_user(user, what)
103
118
  end
104
119
  end
105
- end
120
+ end
106
121
  end
107
122
 
108
123
  end
109
124
 
110
125
  end
126
+
@@ -0,0 +1,3 @@
1
+ module Gimdb
2
+ VERSION = "0.1.0"
3
+ end
@@ -1,4 +1,3 @@
1
- require 'rubygems'
2
1
  require 'nokogiri'
3
2
  require 'open-uri'
4
3
  require 'net/http'
@@ -31,11 +30,17 @@ class IMDB
31
30
  end
32
31
 
33
32
 
33
+ def reset
34
+ @params = nil
35
+ @start = 1
36
+ end
37
+
38
+
34
39
  def get_image(url, path, x = 160)
35
40
  # http://ia.media-imdb.com/images/*.jpg
36
41
  if url.match(/^http:\/\/ia\.media-imdb\.com\/images\/.*\.jpg/)
37
42
  base = url.split('._V1._')[0]
38
- style = "._V1._SX#{160}_.jpg"
43
+ style = "._V1._SX#{x}_.jpg"
39
44
  final = base + style
40
45
  begin
41
46
  File.open(path, 'w') do |f|
@@ -84,19 +89,20 @@ class IMDB
84
89
  doc.css('table.results tr.detailed').each do |movie|
85
90
  info = {}
86
91
  number = movie.css('td.number').first.content.stripper.to_i
87
- info[:code] = movie.css('td.title > a').first[:href].split('/')[2] rescue nil
88
- info[:title] = movie.css('td.title > a').first.content.stripper rescue nil
89
- info[:image_url] = movie.css('td.image img').first[:src].stripper rescue nil
90
- info[:year] = movie.css('td.title > span.year_type').first.content.stripper[1..-2] rescue nil
91
- info[:votes] = movie.css('td.title > div.user_rating').first[:title].stripper.gsub(',','') rescue nil
92
- info[:rating] = movie.css('td.title > div.user_rating').first.content.stripper rescue nil
93
- info[:outline] = movie.css('td.title > span.outline').first.content.stripper rescue nil
94
- info[:credit] = movie.css('td.title > span.credit').first.content.stripper rescue nil
95
- info[:genre] = movie.css('td.title > span.genre').first.content.stripper rescue nil
96
- info[:runtime] = movie.css('td.title > span.runtime').first.content.stripper rescue nil
92
+ info[:code] = movie.css('td.title > a').first[:href].split('/')[2] rescue next
93
+ info[:title] = movie.css('td.title > a').first.content.stripper rescue next
94
+ info[:image_url] = movie.css('td.image img').first[:src].stripper rescue nil
95
+ info[:year] = movie.css('td.title > span.year_type').first.content.stripper[1..-2] rescue nil
96
+ info[:votes] = movie.css('td.sort_col').first.content.gsub(',', '') rescue nil
97
+ info[:rating] = movie.css('td.title span.rating-rating').first.content.stripper rescue nil
98
+ info[:outline] = movie.css('td.title > span.outline').first.content.stripper rescue nil
99
+ info[:credit] = movie.css('td.title > span.credit').first.content.stripper rescue nil
100
+ info[:genre] = movie.css('td.title > span.genre').first.content.stripper rescue nil
101
+ info[:runtime] = movie.css('td.title > span.runtime').first.content.stripper rescue nil
97
102
  list[number] = info
98
103
  end
99
104
  return list
100
105
  end
101
106
 
102
107
  end
108
+
@@ -6,217 +6,254 @@
6
6
  #, fuzzy
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: gimdb\n"
10
- "POT-Creation-Date: 2010-05-08 16:42+0200\n"
11
- "PO-Revision-Date: 2010-05-06 01:50+0200\n"
9
+ "Project-Id-Version: 0.1.0\n"
10
+ "POT-Creation-Date: 2011-09-25 18:29+0200\n"
11
+ "PO-Revision-Date: 2011-09-25 16:49+0200\n"
12
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
+ "Language: \n"
14
15
  "MIME-Version: 1.0\n"
15
16
  "Content-Type: text/plain; charset=UTF-8\n"
16
17
  "Content-Transfer-Encoding: 8bit\n"
17
18
  "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
18
19
 
19
- msgid "Genres"
20
- msgstr ""
21
-
22
- msgid "<b>To see</b>"
23
- msgstr ""
24
-
25
- msgid "<b>Seen</b>"
26
- msgstr ""
27
-
28
- msgid "<b>Favourites</b>"
29
- msgstr ""
30
-
31
- msgid "Searching"
32
- msgstr ""
33
-
34
- msgid "Add"
35
- msgstr ""
36
-
37
- msgid "Edit"
38
- msgstr ""
39
-
40
- msgid "Delete"
41
- msgstr ""
42
-
43
- msgid "New user added"
44
- msgstr ""
45
-
46
- msgid "User edited"
47
- msgstr ""
48
-
49
- msgid "User deleted"
50
- msgstr ""
51
-
52
- msgid "Downloading movie posters"
53
- msgstr ""
54
-
55
- msgid "Building movie boxes"
56
- msgstr ""
57
-
58
- msgid "Downloading movies info"
59
- msgstr ""
60
-
20
+ #: lib/gimdb/ui_translatable_strings.rb:1
61
21
  msgid "GIMDB"
62
22
  msgstr ""
63
23
 
24
+ #: lib/gimdb/ui_translatable_strings.rb:2
64
25
  msgid "_File"
65
26
  msgstr ""
66
27
 
28
+ #: lib/gimdb/ui_translatable_strings.rb:3
67
29
  msgid "Show movies to see"
68
30
  msgstr ""
69
31
 
32
+ #: lib/gimdb/ui_translatable_strings.rb:4
70
33
  msgid "Show movies seen"
71
34
  msgstr ""
72
35
 
36
+ #: lib/gimdb/ui_translatable_strings.rb:5
73
37
  msgid "Show favourites movies"
74
38
  msgstr ""
75
39
 
40
+ #: lib/gimdb/ui_translatable_strings.rb:6
76
41
  msgid "Work offline"
77
42
  msgstr ""
78
43
 
44
+ #: lib/gimdb/ui_translatable_strings.rb:7
79
45
  msgid "_View"
80
46
  msgstr ""
81
47
 
82
- msgid "Select users to manage"
83
- msgstr ""
84
-
48
+ #: lib/gimdb/ui_translatable_strings.rb:8
85
49
  msgid "Select users"
86
50
  msgstr ""
87
51
 
52
+ #: lib/gimdb/ui_translatable_strings.rb:9
88
53
  msgid "Edit users"
89
54
  msgstr ""
90
55
 
91
- msgid "Add or remove users"
92
- msgstr ""
93
-
56
+ #: lib/gimdb/ui_translatable_strings.rb:10
94
57
  msgid "Show sidebar"
95
58
  msgstr ""
96
59
 
60
+ #: lib/gimdb/ui_translatable_strings.rb:11
97
61
  msgid "_Help"
98
62
  msgstr ""
99
63
 
100
- msgid ""
101
- "1\n"
102
- "2\n"
103
- "3\n"
104
- "4\n"
105
- "5\n"
106
- "6\n"
107
- "7\n"
108
- "8\n"
109
- "9\n"
110
- "10"
111
- msgstr ""
112
-
64
+ #: lib/gimdb/ui_translatable_strings.rb:12
113
65
  msgid "Year "
114
66
  msgstr ""
115
67
 
68
+ #: lib/gimdb/ui_translatable_strings.rb:13
69
+ #: lib/gimdb/ui_translatable_strings.rb:15
116
70
  msgid " to "
117
71
  msgstr ""
118
72
 
73
+ #: lib/gimdb/ui_translatable_strings.rb:14
119
74
  msgid "Vote "
120
75
  msgstr ""
121
76
 
77
+ #: lib/gimdb/ui_translatable_strings.rb:16
122
78
  msgid "All"
123
79
  msgstr ""
124
80
 
81
+ #: lib/gimdb/ui_translatable_strings.rb:17
125
82
  msgid "Action"
126
83
  msgstr ""
127
84
 
85
+ #: lib/gimdb/ui_translatable_strings.rb:18
128
86
  msgid "Adventure"
129
87
  msgstr ""
130
88
 
89
+ #: lib/gimdb/ui_translatable_strings.rb:19
131
90
  msgid "Animation"
132
91
  msgstr ""
133
92
 
93
+ #: lib/gimdb/ui_translatable_strings.rb:20
134
94
  msgid "Biography"
135
95
  msgstr ""
136
96
 
97
+ #: lib/gimdb/ui_translatable_strings.rb:21
137
98
  msgid "Comedy"
138
99
  msgstr ""
139
100
 
101
+ #: lib/gimdb/ui_translatable_strings.rb:22
140
102
  msgid "Crime"
141
103
  msgstr ""
142
104
 
105
+ #: lib/gimdb/ui_translatable_strings.rb:23
143
106
  msgid "Documentary"
144
107
  msgstr ""
145
108
 
109
+ #: lib/gimdb/ui_translatable_strings.rb:24
146
110
  msgid "Drama"
147
111
  msgstr ""
148
112
 
113
+ #: lib/gimdb/ui_translatable_strings.rb:25
149
114
  msgid "Family"
150
115
  msgstr ""
151
116
 
117
+ #: lib/gimdb/ui_translatable_strings.rb:26
152
118
  msgid "Fantasy"
153
119
  msgstr ""
154
120
 
121
+ #: lib/gimdb/ui_translatable_strings.rb:27
155
122
  msgid "Film-noir"
156
123
  msgstr ""
157
124
 
125
+ #: lib/gimdb/ui_translatable_strings.rb:28
158
126
  msgid "Game-show"
159
127
  msgstr ""
160
128
 
129
+ #: lib/gimdb/ui_translatable_strings.rb:29
161
130
  msgid "History"
162
131
  msgstr ""
163
132
 
133
+ #: lib/gimdb/ui_translatable_strings.rb:30
164
134
  msgid "Horror"
165
135
  msgstr ""
166
136
 
137
+ #: lib/gimdb/ui_translatable_strings.rb:31
167
138
  msgid "Music"
168
139
  msgstr ""
169
140
 
141
+ #: lib/gimdb/ui_translatable_strings.rb:32
170
142
  msgid "Musical"
171
143
  msgstr ""
172
144
 
145
+ #: lib/gimdb/ui_translatable_strings.rb:33
173
146
  msgid "Mystery"
174
147
  msgstr ""
175
148
 
149
+ #: lib/gimdb/ui_translatable_strings.rb:34
176
150
  msgid "News"
177
151
  msgstr ""
178
152
 
153
+ #: lib/gimdb/ui_translatable_strings.rb:35
179
154
  msgid "Romance"
180
155
  msgstr ""
181
156
 
157
+ #: lib/gimdb/ui_translatable_strings.rb:36
182
158
  msgid "Sci-Fi"
183
159
  msgstr ""
184
160
 
161
+ #: lib/gimdb/ui_translatable_strings.rb:37
185
162
  msgid "Sport"
186
163
  msgstr ""
187
164
 
165
+ #: lib/gimdb/ui_translatable_strings.rb:38
188
166
  msgid "Thriller"
189
167
  msgstr ""
190
168
 
169
+ #: lib/gimdb/ui_translatable_strings.rb:39
191
170
  msgid "War"
192
171
  msgstr ""
193
172
 
173
+ #: lib/gimdb/ui_translatable_strings.rb:40
194
174
  msgid "Western"
195
175
  msgstr ""
196
176
 
197
- msgid "Sort "
177
+ #: lib/gimdb/ui_translatable_strings.rb:41
178
+ msgid "<b>Genres</b>"
198
179
  msgstr ""
199
180
 
200
- msgid ""
201
- "Movie meter\n"
202
- "A-Z\n"
203
- "Rating\n"
204
- "Number of votes\n"
205
- "Runtime\n"
206
- "Year"
181
+ #: lib/gimdb/ui_translatable_strings.rb:42
182
+ msgid "Sort "
207
183
  msgstr ""
208
184
 
185
+ #: lib/gimdb/ui_translatable_strings.rb:43
209
186
  msgid "DESC"
210
187
  msgstr ""
211
188
 
189
+ #: lib/gimdb/ui_translatable_strings.rb:44
212
190
  msgid "Hide seen"
213
191
  msgstr ""
214
192
 
193
+ #: lib/gimdb/ui_translatable_strings.rb:45
215
194
  msgid "Show only to see"
216
195
  msgstr ""
217
196
 
197
+ #: lib/gimdb/ui_translatable_strings.rb:46
218
198
  msgid "Manage users"
219
199
  msgstr ""
220
200
 
201
+ #: lib/gimdb/ui_translatable_strings.rb:47
221
202
  msgid "Select all users"
222
- msgstr ""
203
+ msgstr ""
204
+
205
+ #: lib/gimdb/gimdb.rb:99
206
+ msgid "Movie meter"
207
+ msgstr ""
208
+
209
+ #: lib/gimdb/gimdb.rb:99
210
+ msgid "A-Z"
211
+ msgstr ""
212
+
213
+ #: lib/gimdb/gimdb.rb:99
214
+ msgid "Rating"
215
+ msgstr ""
216
+
217
+ #: lib/gimdb/gimdb.rb:99
218
+ msgid "Number of votes"
219
+ msgstr ""
220
+
221
+ #: lib/gimdb/gimdb.rb:99
222
+ msgid "Runtime"
223
+ msgstr ""
224
+
225
+ #: lib/gimdb/gimdb.rb:99
226
+ msgid "Year"
227
+ msgstr ""
228
+
229
+ #: lib/gimdb/gimdb.rb:185
230
+ msgid "Searching"
231
+ msgstr ""
232
+
233
+ #: lib/gimdb/manager_box.rb:67
234
+ msgid "Add"
235
+ msgstr ""
236
+
237
+ #: lib/gimdb/manager_box.rb:72
238
+ msgid "Delete"
239
+ msgstr ""
240
+
241
+ #: lib/gimdb/manager_box.rb:76
242
+ msgid "Edit"
243
+ msgstr ""
244
+
245
+ #: lib/gimdb/movie_box.rb:70
246
+ msgid "Genres"
247
+ msgstr ""
248
+
249
+ #: lib/gimdb/movie_box.rb:95
250
+ msgid "<b>To see</b>"
251
+ msgstr ""
252
+
253
+ #: lib/gimdb/movie_box.rb:96
254
+ msgid "<b>Seen</b>"
255
+ msgstr ""
256
+
257
+ #: lib/gimdb/movie_box.rb:97
258
+ msgid "<b>Favourites</b>"
259
+ msgstr ""