Compare commits

...

4 commits
v0.1.3 ... 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
13 changed files with 158 additions and 40 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/
/spec/reports/
/tmp/
_build/

View file

@ -11,6 +11,6 @@ gem "minitest", "~> 5.16"
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

@ -26,6 +26,7 @@ GEM
drb (2.2.1)
ffi (1.17.0)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x64-mingw-ucrt)
fileutils (1.7.2)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
@ -107,6 +108,7 @@ GEM
PLATFORMS
arm64-darwin-23
ruby
x64-mingw-ucrt
DEPENDENCIES
minitest (~> 5.16)

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,4 +1,4 @@
require 'fileutils'
require "fileutils"
class Phlexite::Router
def initialize(base, site)
@ -7,25 +7,25 @@ class Phlexite::Router
end
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
end
def page(out_path, component)
out = full_out_path(out_path)
FileUtils::mkdir_p File::dirname(out)
File::write(out, component.call)
FileUtils.mkdir_p File.dirname(out)
File.write(out, component.call)
end
def mount(local_directory, on:)
out = full_out_path(on)
FileUtils::mkdir_p out
FileUtils::cp_r File::join(local_directory, "."), out
FileUtils.mkdir_p out
FileUtils.cp_r File.join(local_directory, "."), out
end
private
private
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

View file

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

View file

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