Compare commits

...

8 commits
v0.1.1 ... main

Author SHA1 Message Date
04e1d9eb91
Try adding docs
Some checks failed
/ build (push) Successful in 1m33s
Ruby / Ruby 3.3.5 (push) Failing after 14s
2025-06-10 18:11:38 -04:00
Aleks Rutins
15c0a1ccc0 Only publish on tags 2024-12-07 17:53:45 -05:00
Aleks Rutins
1602d87b8a Fix lint 2024-12-07 17:47:01 -05:00
Aleks Rūtiņš
77d3de5a03
Create gem-push.yml 2024-12-07 17:42:05 -05:00
Aleks Rūtiņš
1defa59af9 Bump phlexite to 0.1.3 2024-09-09 06:44:26 -04:00
Aleks Rūtiņš
a284657783 Static file support 2024-09-09 06:43:14 -04:00
Aleks Rūtiņš
46b5593cb3 Bump phlexite to 0.1.2 2024-09-09 06:37:34 -04:00
Aleks Rūtiņš
c5bf2416fd Use mkdir_p instead of shelling out 2024-09-09 06:36:55 -04:00
16 changed files with 167 additions and 39 deletions

View file

@ -0,0 +1,17 @@
on:
push:
branches:
- main
jobs:
build:
runs-on: selfhosted
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install dependencies
run: bundle install
- name: Build documentation
run: bundle exec ruby docs/build.rb
- name: Publish site
run: cp -rfv _build/* /srv/docs/phlexite/

View file

@ -0,0 +1,46 @@
name: Ruby Gem
on:
push:
tags: ["*"]
jobs:
build:
name: Build + Publish
runs-on: docs
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Ruby 3.3
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
# uses: ruby/setup-ruby@v1
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
with:
ruby-version: 3.3.x
- name: Publish to GPR
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem build *.gemspec
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
env:
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
OWNER: ${{ github.repository_owner }}
- name: Publish to RubyGems
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem build *.gemspec
gem push *.gem
env:
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"

View file

@ -0,0 +1,27 @@
name: Ruby
on:
push:
branches:
- main
pull_request:
jobs:
build:
runs-on: docker
name: Ruby ${{ matrix.ruby }}
strategy:
matrix:
ruby:
- "3.3.5"
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run the default task
run: bundle exec rake

View file

@ -1,27 +0,0 @@
name: Ruby
on:
push:
branches:
- main
pull_request:
jobs:
build:
runs-on: ubuntu-latest
name: Ruby ${{ matrix.ruby }}
strategy:
matrix:
ruby:
- '3.3.5'
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run the default task
run: bundle exec rake

1
.gitignore vendored
View file

@ -6,3 +6,4 @@
/pkg/ /pkg/
/spec/reports/ /spec/reports/
/tmp/ /tmp/
_build/

View file

@ -11,6 +11,6 @@ gem "minitest", "~> 5.16"
gem "standard", "~> 1.3" gem "standard", "~> 1.3"
gem "phlex", "~> 1.11" gem "phlex", "~> 2.3"
gem "steep", "~> 1.7", :group => :development gem "steep", "~> 1.7", group: :development

View file

@ -1,7 +1,7 @@
PATH PATH
remote: . remote: .
specs: specs:
phlexite (0.1.1) phlexite (0.1.3)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
@ -26,6 +26,7 @@ GEM
drb (2.2.1) drb (2.2.1)
ffi (1.17.0) ffi (1.17.0)
ffi (1.17.0-arm64-darwin) ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x64-mingw-ucrt)
fileutils (1.7.2) fileutils (1.7.2)
i18n (1.14.5) i18n (1.14.5)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
@ -107,6 +108,7 @@ GEM
PLATFORMS PLATFORMS
arm64-darwin-23 arm64-darwin-23
ruby ruby
x64-mingw-ucrt
DEPENDENCIES DEPENDENCIES
minitest (~> 5.16) minitest (~> 5.16)

View file

@ -6,6 +6,7 @@ target :lib do
check "lib" # Directory name check "lib" # Directory name
# ignore "lib/templates/*.rb" # ignore "lib/templates/*.rb"
library "fileutils"
# library "pathname" # Standard libraries # library "pathname" # Standard libraries
# library "strong_json" # Gems # library "strong_json" # Gems
# library "phlex" # library "phlex"

13
docs/build.rb Normal file
View file

@ -0,0 +1,13 @@
require_relative '../lib/phlexite'
require 'phlex'
module Phlexite
module Docs end
end
require_relative 'pages/layout'
require_relative 'pages/index'
Phlexite::Site.new { |s|
s.page 'index.html', Phlexite::Docs::Pages::Index.new
}

10
docs/pages/index.rb Normal file
View file

@ -0,0 +1,10 @@
module Phlexite::Docs::Pages
class Index < ::Phlex::HTML
def view_template
render Layout.new {
h1 { 'Phlexite' }
p { 'Phlexite is a simple static site generator for Ruby.' }
}
end
end
end

29
docs/pages/layout.rb Normal file
View file

@ -0,0 +1,29 @@
module Phlexite::Docs::Pages
class Layout < ::Phlex::HTML
def view_template
doctype
html {
head {
meta charset: 'utf-8'
meta name: 'viewport', content: 'width=device-width, initial-scale=1.0'
title { "Phlexite" }
link rel: 'stylesheet', href: 'https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css'
}
body(style: "padding: 0; margin: 0; display: flex; flex-direction: row; height: 100vh; width: 100vw;") {
aside(style: 'padding: 30px; min-width: 15%; border-right: 1px solid #6F7887;') {
nav {
ul {
li { a(href: '/') { 'Home' } }
}
}
}
div(class: 'container', style: 'padding: 20px') {
yield
}
}
}
end
end
end

View file

@ -1,3 +1,5 @@
require "fileutils"
class Phlexite::Router class Phlexite::Router
def initialize(base, site) def initialize(base, site)
@base = base @base = base
@ -5,19 +7,25 @@ class Phlexite::Router
end end
def group(new_base) def group(new_base)
router = Phlexite::Router.new(File::join(@base, new_base), @site) router = Phlexite::Router.new(File.join(@base, new_base), @site)
yield router yield router
end end
def page(out_path, component) def page(out_path, component)
out = full_out_path(out_path) out = full_out_path(out_path)
system("mkdir -p #{File::dirname(out)}") FileUtils.mkdir_p File.dirname(out)
File::write(out, component.call) File.write(out, component.call)
end end
private def mount(local_directory, on:)
out = full_out_path(on)
FileUtils.mkdir_p out
FileUtils.cp_r File.join(local_directory, "."), out
end
private
def full_out_path(out_path) def full_out_path(out_path)
File::join(@site.build_dir, @site.base_url, @base, out_path) File.join(@site.build_dir, @site.base_url, @base, out_path)
end end
end end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require_relative 'router.rb' require_relative "router"
class Phlexite::Site < Phlexite::Router class Phlexite::Site < Phlexite::Router
attr_accessor :build_dir, :base_url attr_accessor :build_dir, :base_url

View file

@ -1,5 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
module Phlexite module Phlexite
VERSION = "0.1.1" VERSION = "0.1.3"
end end

View file

@ -8,6 +8,7 @@ module Phlexite
def initialize: (String, Site) -> void def initialize: (String, Site) -> void
def page: (String, untyped) -> void def page: (String, untyped) -> void
def group: (String) { (Router) -> void } -> void def group: (String) { (Router) -> void } -> void
def mount: (String, on: String) -> void
private private
def full_out_path: (String) -> String def full_out_path: (String) -> String

View file

@ -12,10 +12,10 @@ class TestPhlexite < Minitest::Test
end end
def test_that_site_is_defined def test_that_site_is_defined
assert ::Phlexite::Site != nil assert !::Phlexite::Site.nil?
end end
def test_that_router_is_defined def test_that_router_is_defined
assert ::Phlexite::Router != nil assert !::Phlexite::Router.nil?
end end
end end