photostat 0.0.1 → 0.0.3

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.
@@ -13,7 +13,7 @@ require "photostat/db/base"
13
13
  require "photostat/plugins/00_base"
14
14
 
15
15
  module Photostat
16
- VERSION = "0.0.1"
16
+ VERSION = "0.0.3"
17
17
 
18
18
  def self.root
19
19
  Pathname.new File.join(File.dirname(__FILE__), 'photostat')
@@ -1,11 +1,13 @@
1
1
  module Photostat
2
2
  class Flickr < Plugins::Base
3
3
  include OSUtils
4
+ include FileUtils
4
5
 
5
6
  help_text "Manages your Flickr account"
6
7
 
7
8
  exposes :config, "Configures Flickr login"
8
9
  exposes :sync, "Uploads local photos to Flickr, downloads Flickr tags / visibility info"
10
+ exposes :export, "Exports web page with thumbnails/links of your public Flickr photos"
9
11
 
10
12
  def activate!
11
13
  return if @activated
@@ -100,13 +102,17 @@ module Photostat
100
102
  end
101
103
  end
102
104
 
103
- visibility = 'private'
104
- visibility = 'protected' if fphoto.isfamily
105
- visibility = 'public' if fphoto.ispublic
105
+ if fphoto.ispublic == 1
106
+ visibility = 'public'
107
+ elsif fphoto.isfamily == 1
108
+ visibility = 'protected'
109
+ else
110
+ visibility = 'private'
111
+ end
106
112
 
107
113
  db[:photos].where(:md5 => md5).update(:has_flickr_upload => true, :visibility => visibility)
108
114
 
109
- STDOUT.write("\r - processed #{count} of #{total}, with #{not_tagged} not tagged on flickr, #{not_local} not local")
115
+ STDOUT.write("\r - reading flickr meta: #{count} of #{total}, with #{not_tagged} not tagged on flickr, #{not_local} not local")
110
116
  STDOUT.flush
111
117
  end
112
118
 
@@ -115,7 +121,44 @@ module Photostat
115
121
  rs = flickr.photos.search(:user_id => "me", :extras => 'machine_tags', :per_page => 500, :page => page_idx)
116
122
  end
117
123
 
118
- puts("\r - processed #{count} of #{total}, with #{not_tagged} not tagged and #{not_local} not local")
124
+ puts("\r - reading flickr meta: #{count} of #{total}, with #{not_tagged} not tagged on flickr, #{not_local} not local")
125
+ end
126
+
127
+ def export
128
+ opts = Trollop::options do
129
+ opt :path, "Local path to export web page to", :required => true, :type => :string, :short => "-p"
130
+ end
131
+
132
+ Trollop::die :path, "must have valid base directory" unless File.directory? File.dirname(opts[:path])
133
+ Trollop::die :path, "directory already exists" if File.directory? opts[:path]
134
+
135
+ activate!
136
+ update_md5_info_on_files!
137
+
138
+ cfg = Photostat.config
139
+ db = Photostat::DB.instance
140
+ Dir.mkdir opts[:path]
141
+
142
+ fh = File.open(File.join(opts[:path], 'index.html'), 'w')
143
+
144
+ rs = flickr.photos.search(:user_id => "me", :extras => 'machine_tags, tags, date_taken, date_upload', :per_page => 500, :privacy_filter => 1)
145
+ rs.each do |fphoto|
146
+ next unless fphoto.machine_tags =~ /checksum:md5=(\w+)/
147
+
148
+ md5 = $1
149
+ obj = db[:photos].where(:md5 => md5).first
150
+
151
+ fname = File.basename obj[:local_path]
152
+ src_path = File.join(cfg[:repository_path], obj[:local_path])
153
+ dst_path = File.join(opts[:path], fname)
154
+
155
+ cp src_path, dst_path
156
+ fh.write "<a href='http://www.flickr.com/photos/alex_ndc/#{fphoto.id}/in/photostream' target='_blank'>\n"
157
+ fh.write " <img src='#{fname}' />\n"
158
+ fh.write "</a>\n"
159
+ end
160
+
161
+ fh.close
119
162
  end
120
163
 
121
164
  def sync
@@ -0,0 +1,32 @@
1
+ module Photostat
2
+ class Query < Plugins::Base
3
+ include OSUtils
4
+
5
+ help_text "For querying the local repo database"
6
+
7
+ exposes :list, "Lists photos corresponding to the filtering criteria"
8
+
9
+ def list
10
+ opts = Trollop::options do
11
+ opt :visibility, "Specifies visibility of photos, choices are private, protected and public", :type => :string
12
+ opt :sort, "Specify sort field, one example being 'created_at'", :type => :string
13
+ opt :reverse, "Reverses output list", :type => :boolean
14
+ opt :absolute, "Output absolute path", :type => :boolean
15
+ end
16
+
17
+ config = Photostat.config
18
+ db = Photostat::DB.instance
19
+
20
+ rs = db[:photos]
21
+ rs = rs.where(:visibility => opts[:visibility]) if opts[:visibility]
22
+ rs = rs.order(opts[:sort].to_sym) if opts[:sort]
23
+ rs = rs.reverse if opts[:reverse]
24
+
25
+ rs.each do |obj|
26
+ path = obj[:local_path]
27
+ path = File.expand_path(File.join(config[:repository_path], path)) if opts[:absolute]
28
+ puts path
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- require "photostat/version"
3
+ require "photostat"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "photostat"
@@ -27,4 +27,5 @@ Gem::Specification.new do |s|
27
27
  s.add_runtime_dependency "flickraw"
28
28
  s.add_runtime_dependency "exifr"
29
29
  s.add_runtime_dependency "json"
30
+ s.add_runtime_dependency "sequel"
30
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: photostat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-29 00:00:00.000000000Z
12
+ date: 2011-10-31 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &74575380 !ruby/object:Gem::Requirement
16
+ requirement: &79120930 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *74575380
24
+ version_requirements: *79120930
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &74575170 !ruby/object:Gem::Requirement
27
+ requirement: &79120610 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *74575170
35
+ version_requirements: *79120610
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sqlite3
38
- requirement: &74574890 !ruby/object:Gem::Requirement
38
+ requirement: &79120350 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *74574890
46
+ version_requirements: *79120350
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: trollop
49
- requirement: &74574610 !ruby/object:Gem::Requirement
49
+ requirement: &79119920 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *74574610
57
+ version_requirements: *79119920
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: escape
60
- requirement: &74574400 !ruby/object:Gem::Requirement
60
+ requirement: &79118850 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *74574400
68
+ version_requirements: *79118850
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: flickraw
71
- requirement: &74574180 !ruby/object:Gem::Requirement
71
+ requirement: &79118400 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *74574180
79
+ version_requirements: *79118400
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: exifr
82
- requirement: &74573940 !ruby/object:Gem::Requirement
82
+ requirement: &79117740 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *74573940
90
+ version_requirements: *79117740
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: json
93
- requirement: &74573730 !ruby/object:Gem::Requirement
93
+ requirement: &79117130 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,7 +98,18 @@ dependencies:
98
98
  version: '0'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *74573730
101
+ version_requirements: *79117130
102
+ - !ruby/object:Gem::Dependency
103
+ name: sequel
104
+ requirement: &79116740 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: *79116740
102
113
  description: Photostat is a collection of command-line utilities for managing photos
103
114
  / syncronizing with Flickr - first version doesnt do much, it just helps me organize
104
115
  my files and upload them to Flickr
@@ -126,6 +137,7 @@ files:
126
137
  - lib/photostat/plugins/00_base.rb
127
138
  - lib/photostat/plugins/01_local.rb
128
139
  - lib/photostat/plugins/02_flickr.rb
140
+ - lib/photostat/plugins/03_query.rb
129
141
  - lib/photostat/utils/os.rb
130
142
  - photostat.gemspec
131
143
  homepage: http://github.com/alexandru/photostat