This commit is contained in:
2026-06-12 15:40:12 -04:00
commit 521653e5de
53 changed files with 8635 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
# encoding: utf-8
class LocalNetwork < ActiveRecord::Base
# attr_accessible :title, :body
# validates :title, :presence => true
# validates :body, :presence => true
has_many :machines
# # belongs_to :someotherthing
# scope :published, -> { order("created_at DESC") }
end
+26
View File
@@ -0,0 +1,26 @@
# encoding: utf-8
class Machine < ActiveRecord::Base
# attr_accessible :title, :body
# validates :title, :presence => true
# validates :body, :presence => true
has_many :services
belongs_to :local_network
# scope :published, -> { order("created_at DESC") }
# def tailscale_ip
# tailscale_ip
# end
def local_domain
"#{domain}.#{local_network.tld}"
end
def local_ip
"#{local_network.subnet}.#{local_ip_octet}"
end
end
+14
View File
@@ -0,0 +1,14 @@
# encoding: utf-8
class Post < ActiveRecord::Base
# attr_accessible :title, :body
# validates :title, :presence => true
# validates :body, :presence => true
# # has_many :somethings
# # belongs_to :someotherthing
# scope :published, -> { order("created_at DESC") }
end
+15
View File
@@ -0,0 +1,15 @@
# encoding: utf-8
class ServiceType < ActiveRecord::Base
# attr_accessible :title, :body
# validates :title, :presence => true
# validates :body, :presence => true
has_many :services, -> { order(position: :asc) }
scope :media, -> { includes(:services).find_by(name: "Media") }
scope :support, -> { includes(:services).find_by(name: "Support") }
scope :admin, -> { includes(:services).find_by(name: "Admin") }
end
+57
View File
@@ -0,0 +1,57 @@
# encoding: utf-8
class Service < ActiveRecord::Base
attr_accessor :current_url
# validates :title, :presence => true
# validates :body, :presence => true
belongs_to :machine
belongs_to :service_type
acts_as_list scope: :service_type
# scope :published, -> { order("created_at DESC") }
def tailscale_ip_url
if machine.tailscale_ip.present?
url = "http://#{machine.tailscale_ip}:#{port}"
if url_path.present?
url.concat(url_path)
end
url
end
end
def local_domain_url
url = "http://"
if subdomain.present?
url.concat("#{subdomain}.")
end
url.concat(machine.local_domain)
if url_path.present?
url.concat(url_path)
end
url
end
def local_ip_url
url = "http://#{machine.local_ip}:#{port}"
if url_path.present?
url.concat(url_path)
end
url
end
def set_current_url(url_type)
if url_type == 'tailscale'
self.current_url = self.tailscale_ip_url
elsif url_type == 'local_ip'
self.current_url = self.local_ip_url
else
self.current_url = self.local_domain_url
end
end
end