Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base: master
...
head fork: vanntastic/imgur
compare: master
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Showing with 49 additions and 4 deletions.
  1. +2 −0  .gitignore
  2. +44 −1 README.rdoc
  3. +2 −2 Rakefile
  4. +1 −1  VERSION
View
2  .gitignore
@@ -3,3 +3,5 @@
coverage
rdoc
pkg
+*.gemspec
+*.gem
View
45 README.rdoc
@@ -1,7 +1,50 @@
= imgur
-Description goes here.
+A simple ruby interface to the imgur image hosting service (http://imgur.com). This is a nice alternative to uploading images and not having to deal with RMagick bs.
+== Requirements
+
+* Grab a imgur api key : http://imgur.com/register/api/
+
+== Examples
+
+ # Uploading an image to imgur from the filesystem
+
+ img = Imgur::API.new 'YOURAPIKEY'
+ uploaded_img = img.upload_file '/path/to/your/test.jpg'
+ # should return a hash like:
+ # => {"small_thumbnail"=>"http://imgur.com/NfuKFs.png",
+ "original_image"=>"http://imgur.com/NfuKF.png",
+ "large_thumbnail"=>"http://imgur.com/NfuKFl.png",
+ "delete_hash"=>"VAiPkk5NoQ", "imgur_page"=>"http://imgur.com/NfuKF",
+ "delete_page"=>"http://imgur.com/delete/VAiPkk5NoQ",
+ "image_hash"=>"NfuKF"}
+ # now you can do something like (if you're using rails):
+ <%= image_tag uploaded_img["small_thumbnail"] %>
+
+ # Here's an example using Sinatra and Sequel, requires sinatra-more
+
+ # Everything's included into one action for brevity, although you can probably extract the file functions to a helper for organizational purposes
+
+ post '/upload_photo' do
+ # let's assume we have this is in our form
+ # <%= file_field_tag :photo %>
+ file_name = params[:photo][:filename].split(".").first.gsub!(/[^a-z0-9]+/i, '_')
+ file_type = params[:photo][:filename].split(".").last
+ tmp_file_path = File.join(APP_ROOT,"public/images/tmp/#{file_name}.#{file_type}")
+ FileUtils.mv params[:photo][:tempfile].path, tmp_file_path
+
+ unless params["photo"].blank? || params["photo"].nil?
+ @uploaded_img = IMGUR.upload_file tmp_file_path
+ end
+
+ @photo = Photo.new(:photo => @uploaded_img)
+ @photo.save
+
+ redirect '/results'
+ end
+
+
== Note on Patches/Pull Requests
* Fork the project.
View
4 Rakefile
@@ -4,12 +4,12 @@ require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
- gem.name = "imgur"
+ gem.name = "vanntastic-imgur"
gem.summary = %Q{Imgur API interface}
gem.description = %Q{An interface to the Imgur API}
gem.email = "jdp34@njit.edu"
gem.homepage = "http://github.com/jdp/imgur"
- gem.authors = ["Justin Poliey"]
+ gem.authors = ["Justin Poliey","Vann Ek"]
gem.add_development_dependency "bacon", ">= 1.1.0"
gem.add_development_dependency "yard", ">= 0.2.3.5"
gem.add_development_dependency "curb", ">= 0.5.4.0"
View
2  VERSION
@@ -1 +1 @@
-0.2.0
+0.3.0

No commit comments for this range

Something went wrong with that request. Please try again.