Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camping example #101

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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