Skip to content

Commit

Permalink
Camping example
Browse files Browse the repository at this point in the history
  • Loading branch information
benpickles committed Nov 9, 2023
1 parent cbc74f8 commit 6e14f11
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions examples/camping/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Gemfile.lock
build
5 changes: 5 additions & 0 deletions examples/camping/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

gem 'camping', '<3'
gem 'parklife', path: '../..'
gem 'rack'
9 changes: 9 additions & 0 deletions examples/camping/Parkfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require_relative 'camp'

Parklife.application.configure do |config|
config.app = App
end

Parklife.application.routes do
root crawl: true
end
43 changes: 43 additions & 0 deletions examples/camping/camp.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6e14f11

Please sign in to comment.