Centralize page definitions

This commit is contained in:
Aleks Rutins 2025-06-05 08:50:14 -04:00
parent f5285561bb
commit 9e3f80b549
No known key found for this signature in database
4 changed files with 15 additions and 18 deletions

View file

@ -5,7 +5,7 @@ GEM
rexml (>= 3.3.9)
phlex (1.11.0)
phlexite (0.1.3)
rexml (3.4.0)
rexml (3.4.1)
PLATFORMS
x64-mingw-ucrt
@ -17,4 +17,4 @@ DEPENDENCIES
phlexite (~> 0.1.3)
BUNDLED WITH
2.5.22
2.6.9

View file

@ -4,6 +4,7 @@ require 'phlex'
require 'phlexite'
require 'kramdown'
require_relative 'lib/pages'
require_relative 'views/base_layout'
require_relative 'views/nav_links'
require_relative 'views/section_link'
@ -11,14 +12,7 @@ require_relative 'views/page_layout'
require_relative 'views/pages/index'
require_relative 'views/pages/markdown_page'
def pages = [
['concepts', 'Concepts of Biocircuits'],
['simplest-circuit', "The Simplest Circuit"],
['repressors', 'Repressors & Leaks'],
['activators', 'Activators'],
['hill-functions', 'Ultrasensitivity & the Hill Function'],
['activators-vs-repressors', 'Choosing Between Activators & Repressors'],
]
def pages = BC.pages
Phlexite::Site.new do |s|
s.mount 'assets', on: '/assets'

10
lib/pages.rb Normal file
View file

@ -0,0 +1,10 @@
module BC
def self.pages = [
['concepts', 'Concepts of Biocircuits'],
['simplest-circuit', "The Simplest Circuit"],
['repressors', 'Repressors & Leaks'],
['activators', 'Activators'],
['hill-functions', 'Ultrasensitivity & the Hill Function'],
['activators-vs-repressors', 'Choosing Between Activators & Repressors'],
]
end

View file

@ -4,14 +4,7 @@ module BC
module Views
module Pages
class Index < ::Phlex::HTML
def sections = {
"1. Concepts of Biocircuits" => "/concepts.html",
"2. The Simplest Circuit" => "/simplest-circuit.html",
"3. Repressors & Leaks" => "/repressors.html",
"4. Activators" => "/activators.html",
"5. Ultrasensitivity & the Hill Function" => "/hill-functions.html",
"6. Choosing Between Activators & Repressors" => "/activators-vs-repressors.html"
}
def sections = BC.pages.each_with_index.map { |page, idx| ["#{idx + 1}. #{page[1]}", "/#{page[0]}.html"] }
def view_template
render(::BC::Views::BaseLayout.new("Home")) do