Browse files

seed file added

  • Loading branch information...
1 parent 271d829 commit e771bfd678c029ab7685e5fb978c52d4de019717 @zlorfi committed Apr 7, 2013
View
3 README.md
@@ -19,9 +19,8 @@
- create `tmp` and `upload` directories (`mkdir tmp upload`) and make them writable for your Apache
- install ImageMagic (`apt-get -y install imagemagick` or `yum -y install ImageMagick.x86_64`)
- install `memcached` for production caching
-- `bundle exec shotgun config.ru` for development (a bit of a warning, `rack_flash` doesn't seem to work with `shotgun`)
-- `bundle exec puma config.ru` for production
- rename `./config/config.yml_default` to `./config/config.yml` and change the setting of `title`, `username` and `password` and most important `token`
+- use the seed file `ruby seed.rb`
## TODO
- image handler exception
View
31 seed.rb
@@ -0,0 +1,31 @@
+#!/usr/bin/env ruby
+
+require 'rubygems' unless RUBY_VERSION >= '1.9'
+require "./app"
+
+App::Picture.all.each do |p|
+ if p.delete
+ begin
+ File.delete("./upload/#{p.image_uid}")
+ p "File: #{p.image_uid} deleted"
+ rescue => e
+ p e.message
+ end
+ end
+end
+
+Dir.glob('./seed_files/*.gif') do |file|
+ app = Dragonfly[:images].configure_with(:imagemagick)
+ prepared_image = app.fetch_file(file).process!(:resize, '1000x1000>')
+ image_uid = app.store(prepared_image)
+ picture = App::Picture.create(image_uid: image_uid, sort_key: App::Picture.get_highest_key)
+ p "Picture with ID #{picture.id} inserted"
+end
+
+def run(command)
+ result = system(command)
+ raise("error, process exited with status #{$?.exitstatus}") unless result
+end
+
+cmd = "bundle exec puma config.ru"
+run cmd
View
BIN seed_files/01.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN seed_files/02.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN seed_files/03.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN seed_files/04.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN seed_files/05.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN seed_files/06.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN seed_files/07.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN seed_files/08.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN seed_files/09.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN seed_files/10.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN seed_files/11.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN seed_files/12.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN seed_files/13.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN seed_files/14.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN seed_files/15.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN seed_files/16.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e771bfd

Please sign in to comment.