Rename documents → files
- Add migration 003 to rename the :documents table to :files
- Rename Document model to FileRecord
- Update web.rb: save_file, db[:files], storage path, ::File prefix
- Update form action to /files, simplify logo markup

https://claude.ai/code/session_018Ym45siELMvsBQj4w9QAXf
change
commit b0da23c2d9738f70f355267cbf53a6d89917bb35
author Alpha Chen <alpha@kejadlen.dev>
date
parent bb7e8932
diff --git a/db/migrate/003_rename_documents_to_files.rb b/db/migrate/003_rename_documents_to_files.rb
new file mode 100644
index 0000000..369e9aa
--- /dev/null
+++ b/db/migrate/003_rename_documents_to_files.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+Sequel.migration do
+  change do
+    rename_table :documents, :files
+  end
+end
diff --git a/lib/models.rb b/lib/models.rb
index dff4000..00acb70 100644
--- a/lib/models.rb
+++ b/lib/models.rb
@@ -1,6 +1,6 @@
 # frozen_string_literal: true
 
 module Domus
-  class Document < Sequel::Model
+  class FileRecord < Sequel::Model(:files)
   end
 end
diff --git a/lib/views/capture.rb b/lib/views/capture.rb
index 40e9be6..dc1e22c 100644
--- a/lib/views/capture.rb
+++ b/lib/views/capture.rb
@@ -37,8 +37,7 @@ module Domus
         header(class: "topbar") do
           a(href: "/", class: "logo") do
             span(class: "logo-mark")
-            plain "domus"
-            span(class: "logo-dot") { plain "." }
+            plain "domus."
           end
         end
       end
@@ -101,7 +100,7 @@ module Domus
             form(
               "x-show": "state === 'saved'",
               method: "post",
-              action: "/documents",
+              action: "/files",
               enctype: "multipart/form-data",
               "@submit.prevent": "false"
             ) do
diff --git a/lib/web.rb b/lib/web.rb
index 35d8671..e5b9abc 100644
--- a/lib/web.rb
+++ b/lib/web.rb
@@ -19,14 +19,14 @@ module Domus
         end
 
         r.post do
-          save_document(r.params)
+          save_file(r.params)
           r.redirect "/"
         end
       end
 
-      r.on "documents" do
+      r.on "files" do
         r.post do
-          save_document(r.params)
+          save_file(r.params)
           r.redirect "/"
         end
       end
@@ -37,20 +37,20 @@ module Domus
     def db = opts[:db] || opts[:app].db
     def storage_path = opts.fetch(:app).config.storage_path
 
-    def save_document(params)
+    def save_file(params)
       upload = params["file"]
       raise ArgumentError, "missing file upload" unless upload.is_a?(Hash) && upload[:tempfile]
 
-      ext = File.extname(upload[:filename].to_s)
+      ext = ::File.extname(upload[:filename].to_s)
       filename = "#{Time.now.strftime("%Y%m%d%H%M%S%L")}#{ext}"
-      dest_dir = File.join(storage_path, "documents")
+      dest_dir = ::File.join(storage_path, "files")
       FileUtils.mkdir_p(dest_dir)
-      dest = File.join(dest_dir, filename)
+      dest = ::File.join(dest_dir, filename)
       FileUtils.cp(upload[:tempfile].path, dest)
 
       now = Time.now
-      db[:documents].insert(
-        path: File.join("documents", filename),
+      db[:files].insert(
+        path: ::File.join("files", filename),
         kind: upload[:type].to_s,
         received_at: now,
         created_at: now