Compare commits
4 commits
Author | SHA1 | Date | |
---|---|---|---|
04e1d9eb91 | |||
|
15c0a1ccc0 | ||
|
1602d87b8a | ||
|
77d3de5a03 |
13 changed files with 158 additions and 40 deletions
17
.forgejo/workflows/docs.yml
Normal file
17
.forgejo/workflows/docs.yml
Normal 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/
|
46
.forgejo/workflows/gem-push.yml
Normal file
46
.forgejo/workflows/gem-push.yml
Normal 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}}"
|
27
.forgejo/workflows/main.yml
Normal file
27
.forgejo/workflows/main.yml
Normal 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
|
27
.github/workflows/main.yml
vendored
27
.github/workflows/main.yml
vendored
|
@ -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
1
.gitignore
vendored
|
@ -6,3 +6,4 @@
|
||||||
/pkg/
|
/pkg/
|
||||||
/spec/reports/
|
/spec/reports/
|
||||||
/tmp/
|
/tmp/
|
||||||
|
_build/
|
||||||
|
|
4
Gemfile
4
Gemfile
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
|
|
13
docs/build.rb
Normal file
13
docs/build.rb
Normal 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
10
docs/pages/index.rb
Normal 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
29
docs/pages/layout.rb
Normal 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
|
|
@ -1,4 +1,4 @@
|
||||||
require 'fileutils'
|
require "fileutils"
|
||||||
|
|
||||||
class Phlexite::Router
|
class Phlexite::Router
|
||||||
def initialize(base, site)
|
def initialize(base, site)
|
||||||
|
@ -7,25 +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)
|
||||||
FileUtils::mkdir_p File::dirname(out)
|
FileUtils.mkdir_p File.dirname(out)
|
||||||
File::write(out, component.call)
|
File.write(out, component.call)
|
||||||
end
|
end
|
||||||
|
|
||||||
def mount(local_directory, on:)
|
def mount(local_directory, on:)
|
||||||
out = full_out_path(on)
|
out = full_out_path(on)
|
||||||
FileUtils::mkdir_p out
|
FileUtils.mkdir_p out
|
||||||
FileUtils::cp_r File::join(local_directory, "."), out
|
FileUtils.cp_r File.join(local_directory, "."), out
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue