Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

create optional groups for qrencoder and phashion

  • Loading branch information...
commit 52622d541571411cba647607d780b01140f05720 1 parent d695c2b
Matthias Hecker 4poc authored
1  .gitignore
View
@@ -7,3 +7,4 @@ public/rack-pagespeed*
public/bundle*
config.yaml
*.swp
+.bundle
21 Gemfile
View
@@ -20,6 +20,23 @@ gem "ruby-filemagic", :require => "filemagic"
gem "mini_magick"
gem "mechanize"
gem "ruby-oembed", :require => "oembed" #, :git => 'git://github.com/jessor/ruby-oembed.git'
-gem "qrencoder"
-gem "phashion", :git => 'git://github.com/4poc/phashion.git'
+
+# qrencoder and phashion are optional features use
+# bundle install --without qrencoder/phashion if you don't want it
+
+group :qrencoder do
+ # QRCodes are used to quickly set the url, email and api secret in the
+ # android application it requires the libqrencoder library to be installed
+ # in the system.
+ gem "qrencoder"
+end
+
+group :phashion do
+ # The original gem does include a custom pHash and cImg tarball that is
+ # built and then linked during install, this fork gets rid of it and
+ # requires both phash and cimg to be installed in the system.
+ # NOTE: phashion violates the GPL by linking with GPL code (phash) and
+ # using the MIT
+ gem "phashion", :git => 'git://github.com/4poc/phashion.git'
+end
36 Gemfile.lock
View
@@ -16,10 +16,10 @@ GIT
GEM
remote: http://rubygems.org/
specs:
- addressable (2.2.7)
+ addressable (2.2.8)
builder (3.0.0)
chunky_png (1.2.5)
- dalli (2.0.2)
+ dalli (2.0.5)
data_objects (0.10.8)
addressable (~> 2.1)
dm-aggregates (1.2.0)
@@ -51,26 +51,26 @@ GEM
data_objects (= 0.10.8)
domain_name (0.5.3)
unf (~> 0.0.3)
- fastercsv (1.5.4)
- haml (3.1.4)
+ fastercsv (1.5.5)
+ haml (3.1.6)
jsmin (1.0.1)
- json (1.6.6)
- json_pure (1.6.6)
- mechanize (2.3)
- domain_name (>= 0.5.1, ~> 0.5)
- mime-types (>= 1.17.2, ~> 1.17)
- net-http-digest_auth (>= 1.1.1, ~> 1.1)
- net-http-persistent (>= 2.5.2, ~> 2.5)
+ json (1.6.7)
+ json_pure (1.6.7)
+ mechanize (2.5.1)
+ domain_name (~> 0.5, >= 0.5.1)
+ mime-types (~> 1.17, >= 1.17.2)
+ net-http-digest_auth (~> 1.1, >= 1.1.1)
+ net-http-persistent (~> 2.5, >= 2.5.2)
nokogiri (~> 1.4)
- ntlm-http (>= 0.1.1, ~> 0.1)
- webrobots (>= 0.0.9, ~> 0.0)
+ ntlm-http (~> 0.1, >= 0.1.1)
+ webrobots (~> 0.0, >= 0.0.9)
mime-types (1.18)
mini_magick (3.4)
subexec (~> 0.2.1)
multi_json (1.0.4)
- net-http-digest_auth (1.2)
+ net-http-digest_auth (1.2.1)
net-http-persistent (2.6)
- nokogiri (1.5.2)
+ nokogiri (1.5.3)
ntlm-http (0.1.1)
qrencoder (1.4.1)
chunky_png (~> 1.1)
@@ -85,7 +85,7 @@ GEM
ruby-filemagic (0.4.2)
ruby-oembed (0.8.7)
rufus-tokyo (1.0.7)
- sass (3.1.15)
+ sass (3.1.19)
shotgun (0.9)
rack (>= 1.0)
sinatra (1.3.2)
@@ -103,11 +103,11 @@ GEM
sinbook
sinbook (0.1.9)
yajl-ruby
- subexec (0.2.1)
+ subexec (0.2.2)
tilt (1.3.3)
unf (0.0.5)
unf_ext
- unf_ext (0.0.4)
+ unf_ext (0.0.5)
webrobots (0.0.13)
yajl-ruby (1.1.0)
0  public/asset/.gitignore
View
No changes.
2  views/api_secret.haml
View
@@ -5,7 +5,7 @@
%p The following key can be used as a shared secret to authenticate API access:
#api_secret #{@api_secret}
- - if settings.qrcode[:active]
+ - if @qrcode_active
%img#qrcode{:src => '/api_secret/qrcode.png'}
- if @redirect
20 zeitgeist.rb
View
@@ -1,7 +1,7 @@
require 'rubygems'
require 'bundler/setup'
-Bundler.require(:default)
+Bundler.require(:default, :qrencoder, :phashion)
# ruby core requirements
require 'base64'
@@ -227,19 +227,15 @@ class Item
# animated autotagging
self.tags << Tag.first_or_create(:tagname => 'animated') if localtemp.animated
- # calculate fingerprint for images
- # and use the fingerprint to check for duplicates
- if self.type == 'image'
+ # duplication check
+ if defined? Phashion and self.type == 'image'
self.fingerprint = self.generate_fingerprint(tempfile)
if (item = Item.first(:fingerprint => self.fingerprint))
raise DuplicateError.new(item.id)
end
- elsif self.type == 'video'
- # checks the md5 for now, (of the preview pic)
- if localtemp.checksum and (item = Item.first(:checksum => localtemp.checksum))
- raise DuplicateError.new(item.id)
- end
- # TODO: audio
+ else #just use md5 checksum as a fallback
+ item = Item.first(:checksum => self.checksum)
+ raise DuplicateError.new(item.id) if item
end
# store file in configured storage
@@ -1052,7 +1048,7 @@ def weighted_size(count, min, max)
get '/api_secret/qrcode.png' do
user = current_user.db_instance
- if settings.qrcode[:active]
+ if settings.qrcode[:active] and defined? QREncoder
api_secret = user.api_secret
qrcode_data = '%s#auth:%s|%s' % [base_url, user.email, api_secret]
qrcode = QREncoder.encode(qrcode_data)
@@ -1067,6 +1063,8 @@ def weighted_size(count, min, max)
redirect '/login'
end
+ @qrcode_active = (settings.qrcode[:active] and defined? QREncoder)
+
user = current_user.db_instance
if not user.api_secret or params[:regenerate]
@api_secret = random_token 48
Please sign in to comment.
Something went wrong with that request. Please try again.