Upgrade all versions

This commit is contained in:
Aaron Fischer 2018-03-20 21:33:32 +01:00 committed by Aaron Fischer
parent a4be9ac462
commit ae573ccfb1
No known key found for this signature in database
GPG key ID: A62EFAEA293B99D7
4 changed files with 94 additions and 96 deletions

71
README
View file

@ -1,71 +0,0 @@
oooo ooo .ooooo. ooo. .oo. oooo oooo
`88. .8' d88' `88b `888P"Y88b `888 `888
`88..8' 888ooo888 888 888 888 888
`888' 888 .o 888 888 888 888
.8' `Y8bod8P' o888o o888o `V88V"V8P'
.o..P'
`Y8P' the image sharing tool for friends.
yenu is a simple tool to share images among a trusted group of people. No
complicated setup, no fancy features nobody really uses, no role management,
no cloud, no bullshit. Just sharing images to people you like and store
your data where you want it to be.
--{ INSTALL }------------------------------------------------------------------
Create the database schema and all needed folders. You need to execute
this only once for initial setup. IF you upgrade the yenu version (replace
the yenu.jar file), it is sometimes needed to run the migrate step again.
$ java -jar yenu.jar migrate
Start the application with the following command in a screen session or
write a systemd init file for that.
$ java -jar yenu.jar
If you like docker, you can use docker-compose to boot up the application
and send it to the background.
$ docker-compose up -d
--{ CONFIGURATION }------------------------------------------------------------
The application is configured with the yenu.properties file. Open the file
in your preferred editor and change the variables as you like. You can change
the basepath, port and other stuff like the user password and the creator
password.
--{ WHERE IS MY DATA? }--------------------------------------------------------
All your images are placed in the data/gallery/ directory, next to the
yenu.jar. When uploading a image, the raw file is placed into the raw/ folder,
if you need the original later (pull out some metadata like GPS coordinates,
scale it into other formats, print it etc.) In the normal/ folder there are
the scaled down images for the details page. The thumbnails/ folder contains
the quare images for the thumbnail preview.
The database used is a SQLite3 database, stored in the yenu.db file. You
can open the database at any time with your favourite sqlite3 client.
$ sqlite3 yenu.db
> .tables
> SELECT * FROM images;
> ...
--{ WHERE CAN IS RUN THIS THING? }---------------------------------------------
Quick answer: Wherever you want. You can boot up a Amazon S3 node and deploy
it there or you put it on your RaspberryPi and host it yourself from your
own internet connection from home (preferred way!). You can also rent a
vServer and deploy it there. All you need is a Java RE and a internet
connection.
--{ LICENSE, RIGHTS AND AUTHOR }-----------------------------------------------
This tool is written by Aaron Fischer (aaron-fischer.net). It is free to use
and is placed under the GPL v.3. The images, comments and other metadata
belongs to you. Make sure, you store the data on a place you trust and make
backups.

57
_scripts/migrate.rb Executable file
View file

@ -0,0 +1,57 @@
#!/usr/bin/env ruby
require "rubygems"
require "sqlite3"
require "pp"
require "date"
require "reverse_markdown"
require "fileutils"
mg_db = SQLite3::Database.new "baby-mediagoblin/mediagoblin.db"
yenu_db = SQLite3::Database.new "yenu_dev.db"
data_dir = 'baby-mediagoblin/user_dev/media/public/media_entries'
target_data_dir = '/home/aaron/workbench/yenu/data/to-process'
# Read all images, comments, tags
# Associate the image, build the hash, move to target
mg_db.execute("SELECT id, title, created, description FROM core__media_entries ORDER BY created ASC") do |entry|
entry_id, title, created, description = entry
created = DateTime.parse(created).strftime('%F %T')
description = ReverseMarkdown.convert(description)
comments = mg_db.execute("SELECT user.username, c.created, c.content FROM core__media_comments AS c INNER JOIN core__users AS user ON user.id = c.author WHERE c.media_entry = "+entry_id.to_s+" ORDER BY c.created ASC")
tags = mg_db.execute("SELECT name FROM core__media_tags WHERE media_entry = "+entry_id.to_s).flatten
filepath = nil
Dir.glob(data_dir + '/' + entry_id.to_s + '/*').each do |file|
next if file =~ /.*(thumbnail|medium)\..*/
filepath = file
end
yenu_db.execute("INSERT INTO images (hash, title, description, created_at)
VALUES ('<"+entry_id.to_s+">', '"+SQLite3::Database.quote(title)+"', '"+SQLite3::Database.quote(description)+"', '"+created+"')")
new_id = yenu_db.last_insert_row_id
comments.each do |comment|
username, created, content = comment
created = DateTime.parse(created).strftime('%F %T')
yenu_db.execute("INSERT INTO comments (image_id, author, comment, created_at)
VALUES ('"+new_id.to_s+"', '"+username+"', '"+SQLite3::Database.quote(content)+"', '"+created+"')")
end
tags.each do |tag|
yenu_db.execute('INSERT OR IGNORE INTO tags (tagname)
VALUES ("'+tag+'")')
tag_id = yenu_db.execute('SELECT id FROM tags WHERE tagname = "'+tag+'"')[0][0]
yenu_db.execute('INSERT INTO image_tags (image_id, tag_id)
VALUES ("'+new_id.to_s+'", "'+tag_id.to_s+'")')
end
if filepath and ['.jpg', '.JPG', '.jpeg', '.JPEG', '.png', '.PNG'].include?(File.extname(filepath))
new_filename = new_id.to_s + File.extname(filepath)
puts "#{filepath} => #{new_filename}"
FileUtils.cp(filepath, File.join(target_data_dir, new_filename))
else
puts "ERROR: File not imported: #{filepath}"
end
end

13
_scripts/migration.clj Normal file
View file

@ -0,0 +1,13 @@
(ns yenu.db.migration
(:require [yenu.helpers.images :as image]
[me.raynes.fs :as fs]
[yenu.db.core :as db]))
(defn migrate-image [image-path]
(let [new-id (fs/base-name image-path true)
hash (image/scale-image-and-save image-path)]
(db/set-image-hash {:hash hash :id new-id})))
(defn start-migration []
(let [images (fs/list-dir (image/data-path "to-process"))]
(run! migrate-image images)))

View file

@ -3,37 +3,36 @@
:url "https://yenu.de/"
:dependencies [[bouncer "1.0.1"]
[compojure "1.5.2"]
[conman "0.6.3"]
[cprop "0.1.10"]
[luminus-immutant "0.2.3"]
[luminus-migrations "0.2.9"]
[compojure "1.6.0"]
[conman "0.6.7"]
[cprop "0.1.11"]
[luminus-immutant "0.2.4"]
[luminus-migrations "0.5.0"]
[luminus-nrepl "0.1.4"]
[metosin/ring-http-response "0.8.1"]
[mount "0.1.11"]
[org.clojure/clojure "1.8.0"]
[metosin/ring-http-response "0.9.0"]
[mount "0.1.12"]
[org.clojure/clojure "1.9.0"]
[org.clojure/tools.cli "0.3.5"]
[org.clojure/tools.logging "0.3.1"]
[org.webjars.bower/tether "1.4.0"]
[org.webjars/jquery "3.2.0"]
[org.webjars/bootstrap "4.0.0-alpha.6-1"]
[org.webjars/font-awesome "4.7.0"]
[org.clojure/tools.logging "0.4.0"]
[org.webjars.bower/tether "1.4.3"]
[org.webjars/jquery "3.3.1"]
[org.webjars/bootstrap "4.0.0-2"]
[org.webjars/font-awesome "5.0.6"]
[org.webjars/webjars-locator-jboss-vfs "0.1.0"]
[org.xerial/sqlite-jdbc "3.16.1"]
[ring-webjars "0.1.1"]
[org.xerial/sqlite-jdbc "3.21.0"]
[ring-webjars "0.2.0"]
[ring-middleware-format "0.7.2"]
[ring/ring-core "1.5.1"]
[ring/ring-defaults "0.2.3"]
[selmer "1.10.6"]
[ring/ring-core "1.6.3"]
[ring/ring-defaults "0.3.1"]
[selmer "1.11.7"]
[hiccup "1.0.5"]
[image-resizer "0.1.9"]
[me.raynes/fs "1.4.6"]
[digest "1.4.5"]
[markdown-clj "0.9.98"]
[image-resizer "0.1.10"]
[me.raynes/fs "1.4.6"] ;; R.I.P. Anthony!
[digest "1.4.7"]
[markdown-clj "1.0.2"]
[clj-exif-orientation "0.2.1"]
[markdown-clj "0.9.98"]
[clj-time "0.8.0"]
[buddy/buddy-auth "1.4.1"]]
[clj-time "0.14.2"]
[buddy/buddy-auth "2.1.0"]]
:min-lein-version "2.0.0"