diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 6c1a138..0bc9d1c 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -3,6 +3,21 @@ name: Examples on: push jobs: + camping: + runs-on: ubuntu-latest + name: Camping example + steps: + - uses: actions/checkout@v3 + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + ruby-version: '3.2' + working-directory: examples/camping + - run: bundle exec parklife build + working-directory: examples/camping + - run: test -f build/index.html + working-directory: examples/camping + rack: runs-on: ubuntu-latest name: Rack example diff --git a/examples/camping/.gitignore b/examples/camping/.gitignore new file mode 100644 index 0000000..b90ed17 --- /dev/null +++ b/examples/camping/.gitignore @@ -0,0 +1,2 @@ +Gemfile.lock +build diff --git a/examples/camping/Gemfile b/examples/camping/Gemfile new file mode 100644 index 0000000..fa6c7d4 --- /dev/null +++ b/examples/camping/Gemfile @@ -0,0 +1,5 @@ +source 'https://rubygems.org' + +gem 'camping', '<3' +gem 'parklife', path: '../..' +gem 'rack' diff --git a/examples/camping/Parkfile b/examples/camping/Parkfile new file mode 100644 index 0000000..ff11a6d --- /dev/null +++ b/examples/camping/Parkfile @@ -0,0 +1,9 @@ +require_relative 'camp' + +Parklife.application.configure do |config| + config.app = App +end + +Parklife.application.routes do + root crawl: true +end diff --git a/examples/camping/camp.rb b/examples/camping/camp.rb new file mode 100644 index 0000000..3609d5d --- /dev/null +++ b/examples/camping/camp.rb @@ -0,0 +1,43 @@ +require 'camping' + +Camping.goes :App + +module App::Controllers + class Index + def get + render :index + end + end + + class PostsX + def get(id) + @id = id + render :show + end + end +end + +module App::Views + def layout + html do + head { title 'Parklife Camping example' } + body do + self << yield + end + end + end + + def index + ul do + %w(foo bar baz).each do |id| + li do + a(href: "/posts/#{id}") { id } + end + end + end + end + + def show + h1 { @id } + end +end