summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.gitattributes3
-rw-r--r--app/controllers/api/v1/games_controller.rb20
-rw-r--r--app/models/game.rb25
-rwxr-xr-xbin/docker-entrypoint1
-rw-r--r--db/lfs/Games/Bubbles, Behind/card.pngbin0 -> 131979 bytes
-rw-r--r--db/lfs/Games/Bubbles, Behind/character.pngbin0 -> 4822 bytes
-rw-r--r--db/lfs/Games/Bubbles, Behind/index.zipbin0 -> 5570496 bytes
-rw-r--r--db/lfs/Games/Bubbles, Behind/title.pngbin0 -> 92223 bytes
-rw-r--r--db/lfs/Games/Magnet Run/card.pngbin0 -> 291501 bytes
-rw-r--r--db/lfs/Games/Magnet Run/character.pngbin0 -> 150426 bytes
-rw-r--r--db/lfs/Games/Magnet Run/index.zipbin0 -> 11171068 bytes
-rw-r--r--db/lfs/Games/Magnet Run/title.pngbin0 -> 183420 bytes
-rw-r--r--db/lfs/Games/Optimal Direction/card.pngbin0 -> 61166 bytes
-rw-r--r--db/lfs/Games/Optimal Direction/character.pngbin0 -> 17188 bytes
-rw-r--r--db/lfs/Games/Optimal Direction/index.zipbin0 -> 8119624 bytes
-rw-r--r--db/lfs/Games/Optimal Direction/title.pngbin0 -> 179422 bytes
-rw-r--r--db/lfs/Games/Orc: Arena of Time/card.pngbin0 -> 6246 bytes
-rw-r--r--db/lfs/Games/Orc: Arena of Time/character.pngbin0 -> 4502 bytes
-rw-r--r--db/lfs/Games/Orc: Arena of Time/index.zipbin0 -> 5181123 bytes
-rw-r--r--db/lfs/Games/Orc: Arena of Time/title.pngbin0 -> 1326 bytes
-rw-r--r--db/seeds.rb117
21 files changed, 145 insertions, 21 deletions
diff --git a/.gitattributes b/.gitattributes
index 8dc4323..56528f1 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,9 +1,8 @@
# See https://git-scm.com/docs/gitattributes for more about git attribute files.
-
# Mark the database schema as having been generated.
db/schema.rb linguist-generated
-
# Mark any vendored files as having been vendored.
vendor/* linguist-vendored
config/credentials/*.yml.enc diff=rails_credentials
config/credentials.yml.enc diff=rails_credentials
+db/lfs/ filter=lfs diff=lfs merge=lfs -text
diff --git a/app/controllers/api/v1/games_controller.rb b/app/controllers/api/v1/games_controller.rb
index 6a412c8..4346244 100644
--- a/app/controllers/api/v1/games_controller.rb
+++ b/app/controllers/api/v1/games_controller.rb
@@ -25,25 +25,7 @@ class Api::V1::GamesController < ApplicationController
end
end
- Zip::File.open(params[:game][:zip]) do |zipfile|
-
- zipfile.each do |entry|
- if entry.file?
- path_name = entry.name.rpartition('/')
- name_extension = path_name.last.rpartition('.')
-
- Tempfile.open([name_extension.first, name_extension[1] + name_extension.last]) do |temp_file|
- entry.extract(temp_file.path) { true }
- @game.game_files.attach(io: File.open(temp_file.path), filename: path_name.last)
- @game.game_files.last.blob.filepath = path_name.first.delete_suffix('/').delete_prefix('/')
-
- # saving the game wont have the blob saved so we need to do it manually
- @game.game_files.last.blob.save
- end
-
- end
- end
- end
+ @game.save_zip(params[:game][:zip])
if @game.save
render json: @game, status: :created
diff --git a/app/models/game.rb b/app/models/game.rb
index 1eb75ff..e30dfae 100644
--- a/app/models/game.rb
+++ b/app/models/game.rb
@@ -1,3 +1,5 @@
+require "zip"
+
class Game < ApplicationRecord
enum status: { draft: 0, published: 1 }
#enum status: {
@@ -11,4 +13,27 @@ class Game < ApplicationRecord
has_one_attached :char_img
has_one_attached :title_img
has_and_belongs_to_many :tags
+
+ def save_zip(zip)
+ Zip::File.open(zip) do |zipfile|
+
+ zipfile.each do |entry|
+ if entry.file?
+ path_name = entry.name.rpartition('/')
+ name_extension = path_name.last.rpartition('.')
+
+ Tempfile.open([name_extension.first, name_extension[1] + name_extension.last]) do |temp_file|
+ entry.extract(temp_file.path) { true }
+ self.game_files.attach(io: File.open(temp_file.path), filename: path_name.last)
+ self.game_files.last.blob.filepath = path_name.first.delete_suffix('/').delete_prefix('/')
+
+ # saving the game wont have the blob saved so we need to do it manually
+ self.game_files.last.blob.save
+ end
+
+ end
+ end
+ end
+
+ end
end
diff --git a/bin/docker-entrypoint b/bin/docker-entrypoint
index fe91345..c4f7422 100755
--- a/bin/docker-entrypoint
+++ b/bin/docker-entrypoint
@@ -3,6 +3,7 @@
# If running the rails server then create or migrate existing database
if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then
./bin/rails db:prepare
+ ./bin.rails db:seed
fi
exec "${@}"
diff --git a/db/lfs/Games/Bubbles, Behind/card.png b/db/lfs/Games/Bubbles, Behind/card.png
new file mode 100644
index 0000000..4100514
--- /dev/null
+++ b/db/lfs/Games/Bubbles, Behind/card.png
Binary files differ
diff --git a/db/lfs/Games/Bubbles, Behind/character.png b/db/lfs/Games/Bubbles, Behind/character.png
new file mode 100644
index 0000000..b8661dd
--- /dev/null
+++ b/db/lfs/Games/Bubbles, Behind/character.png
Binary files differ
diff --git a/db/lfs/Games/Bubbles, Behind/index.zip b/db/lfs/Games/Bubbles, Behind/index.zip
new file mode 100644
index 0000000..a18f881
--- /dev/null
+++ b/db/lfs/Games/Bubbles, Behind/index.zip
Binary files differ
diff --git a/db/lfs/Games/Bubbles, Behind/title.png b/db/lfs/Games/Bubbles, Behind/title.png
new file mode 100644
index 0000000..718918a
--- /dev/null
+++ b/db/lfs/Games/Bubbles, Behind/title.png
Binary files differ
diff --git a/db/lfs/Games/Magnet Run/card.png b/db/lfs/Games/Magnet Run/card.png
new file mode 100644
index 0000000..5a942da
--- /dev/null
+++ b/db/lfs/Games/Magnet Run/card.png
Binary files differ
diff --git a/db/lfs/Games/Magnet Run/character.png b/db/lfs/Games/Magnet Run/character.png
new file mode 100644
index 0000000..beb1fbe
--- /dev/null
+++ b/db/lfs/Games/Magnet Run/character.png
Binary files differ
diff --git a/db/lfs/Games/Magnet Run/index.zip b/db/lfs/Games/Magnet Run/index.zip
new file mode 100644
index 0000000..1251e4d
--- /dev/null
+++ b/db/lfs/Games/Magnet Run/index.zip
Binary files differ
diff --git a/db/lfs/Games/Magnet Run/title.png b/db/lfs/Games/Magnet Run/title.png
new file mode 100644
index 0000000..b272849
--- /dev/null
+++ b/db/lfs/Games/Magnet Run/title.png
Binary files differ
diff --git a/db/lfs/Games/Optimal Direction/card.png b/db/lfs/Games/Optimal Direction/card.png
new file mode 100644
index 0000000..ff6223f
--- /dev/null
+++ b/db/lfs/Games/Optimal Direction/card.png
Binary files differ
diff --git a/db/lfs/Games/Optimal Direction/character.png b/db/lfs/Games/Optimal Direction/character.png
new file mode 100644
index 0000000..1fd4e20
--- /dev/null
+++ b/db/lfs/Games/Optimal Direction/character.png
Binary files differ
diff --git a/db/lfs/Games/Optimal Direction/index.zip b/db/lfs/Games/Optimal Direction/index.zip
new file mode 100644
index 0000000..4f169ec
--- /dev/null
+++ b/db/lfs/Games/Optimal Direction/index.zip
Binary files differ
diff --git a/db/lfs/Games/Optimal Direction/title.png b/db/lfs/Games/Optimal Direction/title.png
new file mode 100644
index 0000000..d155fd7
--- /dev/null
+++ b/db/lfs/Games/Optimal Direction/title.png
Binary files differ
diff --git a/db/lfs/Games/Orc: Arena of Time/card.png b/db/lfs/Games/Orc: Arena of Time/card.png
new file mode 100644
index 0000000..c757a53
--- /dev/null
+++ b/db/lfs/Games/Orc: Arena of Time/card.png
Binary files differ
diff --git a/db/lfs/Games/Orc: Arena of Time/character.png b/db/lfs/Games/Orc: Arena of Time/character.png
new file mode 100644
index 0000000..2e46e51
--- /dev/null
+++ b/db/lfs/Games/Orc: Arena of Time/character.png
Binary files differ
diff --git a/db/lfs/Games/Orc: Arena of Time/index.zip b/db/lfs/Games/Orc: Arena of Time/index.zip
new file mode 100644
index 0000000..b29fb85
--- /dev/null
+++ b/db/lfs/Games/Orc: Arena of Time/index.zip
Binary files differ
diff --git a/db/lfs/Games/Orc: Arena of Time/title.png b/db/lfs/Games/Orc: Arena of Time/title.png
new file mode 100644
index 0000000..311fdb4
--- /dev/null
+++ b/db/lfs/Games/Orc: Arena of Time/title.png
Binary files differ
diff --git a/db/seeds.rb b/db/seeds.rb
index 83840d6..3c76d2b 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -8,6 +8,65 @@
# MovieGenre.find_or_create_by!(name: genre_name)
# end
+markdown_sample = <<~HEREDOC
+# Telum vim lactente
+
+## Petebam Circe hic mactare vitae tandem super
+
+Lorem markdownum Perseu tetigisse instar. Negat inde calidi sibi, in ora
+sanguine; vox excitus pes, in in tibi mella! Portasse morte hic venit, latebras
+varios servire libera; hic ad augusta forcipe, *illis* est ubi atque.
+
+Veri inquit pondere. Precatur ego Amymonen quae vidit lunares caput, nequeo, et.
+Occidat in nosset pressa, nomine exercita penitus viae gaudent extemplo.
+Mensuraque imitamine primum: sine est suas, quo in, est falso est accingere
+ibimus ore renuente. Trahit sua nulla per ut vestigia celerique, gemit manes,
+quo suae.
+
+```
+if (graphic_veronica_traceroute + scanRdram < bittorrent_dtd +
+ bugWindowsOrientation) {
+ pitchWord = dllTrackbackRemote;
+ jquery.batchDot.megabyte(cookie - public, memoryDslamSlashdot(2,
+ socialPpcEncryption));
+}
+cron_analyst = ddr_zettabyte_mips;
+var digitize = 1;
+var friend_gui = artificial.system(alphaWebsite + domain_ibm(
+ install_ospf_definition, mca_camelcase, 4), 551649, active_trinitron(
+ microcomputer_spoofing));
+```
+
+Ungues in cannae limumque ingrate; in una voce cubitoque fecit. Non nec, uno
+vires laesit perque carpere vultus armenta. Via [praetulit clipei
+vestis](http://antro.net/) vidit, sive vestes invitas pro ad per nato nam beati.
+
+## Nec hauriret stantis
+
+Illa serpentem fugit inlaesas, cum spoliis vultum arbitrium penates fulmina
+caelestia moriens videt insidias. Umidus positi, et ripis feremur sit capit
+detur tenens.
+
+- Provolat cum ecce dextro sed suum pomi
+- Voce falsa habuit te
+- Modo deponere bracchia pectus
+
+Deus canor incurva usu dolisque tuentes, leto Liber iniquae requies declivis ad
+fontibus tali, flagratque aquaticus. Rupit stimuloque, conscia, nimiumque ait
+nomen est Libycas, undas.
+
+> Humumque spectata et vera, **rugosis causam** iaculo sacra, iunctas rege
+> triplices contrahit. Potenti unum cava fama genitor testata summa. Comae sit
+> cum, dignissima tauri, formatus promissis *in* quoque [quem
+> candidaque](http://sulcomaxima.net/), vitalesque? Pro edere rescindere, premit
+> mortisque celeri egredior mare pater, una. Arva tu annos fila valles nocte,
+> sero deum densetur **soror siccatque Aeacide** certe undique discordia latent
+> et.
+
+Mihi aureus. Eque tuo, illam diris, virgineas erit externis stabula saetae datis
+videat vultus depositae nymphas pedum non peto quem.
+HEREDOC
+
platform_tags = [
"web",
"desktop",
@@ -27,3 +86,61 @@ game_tags = [
game_tags.each do |tag|
Tag.find_or_create_by!(name: tag, tag_type: "game")
end
+
+User.create({ user_name: "realtradam", identifier: "11139432"})
+user = User.first
+
+data_dir = Rails.root.join('db/lfs')
+
+games = [
+ {
+ title: 'Orc: Arena of Time',
+ description: markdown_sample,
+ github_link: 'https://github.com/realtradam/orc-arena-of-time',
+ img_rendering: 'pixelated',
+ tags: ["web", "desktop"]
+ },
+ {
+ title: 'Bubbles, Behind',
+ description: markdown_sample,
+ github_link: 'https://github.com/realtradam/TOJam2023',
+ img_rendering: 'crisp-edges',
+ tags: ["web", "desktop"]
+ },
+ {
+ title: 'Magnet Run',
+ description: markdown_sample,
+ github_link: 'https://github.com/realtradam/Magnet-Run-3D',
+ img_rendering: 'crisp-edges',
+ tags: ["web", "desktop"]
+ },
+ {
+ title: 'Optimal Direction',
+ description: markdown_sample,
+ github_link: 'https://github.com/realtradam/optimal-direction',
+ img_rendering: 'crisp-edges',
+ tags: ["web", "desktop"]
+ },
+]
+
+games.each do |game|
+ next if Game.exists(title: game[:title], user_id: 0) # first user is always me
+ tags = game[:tags]
+ game.delete(:tags)
+ game_obj = user.games.new(game)
+ game_obj.save_zip("#{data_dir}/Games/#{game[:title]}/index.zip")
+ game_obj.card_img.attach(io: File.open("#{data_dir}/Games/#{game[:title]}/card.png"), filename: 'card.png')
+ game_obj.char_img.attach(io: File.open("#{data_dir}/Games/#{game[:title]}/character.png"), filename: 'character.png')
+ game_obj.title_img.attach(io: File.open("#{data_dir}/Games/#{game[:title]}/title.png"), filename: 'title.png')
+ game_obj.titleSlug = game[:title].parameterize
+ game_obj.status = 1
+
+ tags.each do |tag|
+ tag_obj = Tag.find_by(tag_type: "platform", name: tag)
+ if tag_obj
+ game_obj.tags << tag_obj
+ end
+ end
+
+ game_obj.save
+end