Skip to content

Commit

Permalink
Roda example (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
benpickles authored Nov 8, 2023
2 parents 2472810 + c75518e commit cbc74f8
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 45 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Examples

on: push

jobs:
rack:
runs-on: ubuntu-latest
name: Rack example
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: '2.7'
working-directory: examples/rack
- run: bundle exec parklife build
working-directory: examples/rack
- run: test -f build/index.html
working-directory: examples/rack

rails:
runs-on: ubuntu-latest
name: Rails example
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: '3.2'
working-directory: examples/rails
- run: bin/static-build
working-directory: examples/rails
- run: test -f build/index.html
working-directory: examples/rails

roda:
runs-on: ubuntu-latest
name: Roda example
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: '3.2'
working-directory: examples/roda
- run: bundle exec parklife build
working-directory: examples/roda
- run: test -f build/index.html
working-directory: examples/roda

sinatra:
runs-on: ubuntu-latest
name: Sinatra example
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: '2.7'
working-directory: examples/sinatra
- run: bundle exec parklife build
working-directory: examples/sinatra
- run: test -f build/index.html
working-directory: examples/sinatra
45 changes: 0 additions & 45 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,6 @@ name: Tests
on: push

jobs:
example_rack:
runs-on: ubuntu-latest
name: Rack example
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: '2.7'
working-directory: examples/rack
- run: bundle exec parklife build
working-directory: examples/rack
- run: test -f build/index.html
working-directory: examples/rack

example_rails:
runs-on: ubuntu-latest
name: Rails example
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: '3.2'
working-directory: examples/rails
- run: bin/static-build
working-directory: examples/rails
- run: test -f build/index.html
working-directory: examples/rails

example_sinatra:
runs-on: ubuntu-latest
name: Sinatra example
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: '2.7'
working-directory: examples/sinatra
- run: bundle exec parklife build
working-directory: examples/sinatra
- run: test -f build/index.html
working-directory: examples/sinatra

rspec:
runs-on: ubuntu-latest
strategy:
Expand Down
2 changes: 2 additions & 0 deletions examples/roda/.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/roda/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

gem 'parklife', path: '../..'
gem 'roda'
gem 'tilt'
9 changes: 9 additions & 0 deletions examples/roda/Parkfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require_relative 'app'

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

Parklife.application.routes do
root crawl: true
end
20 changes: 20 additions & 0 deletions examples/roda/app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'roda'

class App < Roda
plugin :render

route do |r|
r.root do
view 'home'
end

r.on 'posts' do
r.is String do |id|
r.get do
@id = id
view 'show'
end
end
end
end
end
7 changes: 7 additions & 0 deletions examples/roda/views/home.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<h1>Home</h1>

<ul>
<% %w(foo bar baz).each do |id| %>
<li><a href="/posts/<%= id %>"><%= id %></a></li>
<% end %>
</ul>
8 changes: 8 additions & 0 deletions examples/roda/views/layout.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
<head>
<title>Parklife Roda example</title>
</head>
<body>
<%= yield %>
</body>
</html>
1 change: 1 addition & 0 deletions examples/roda/views/show.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Show <%= @id %></h1>

0 comments on commit cbc74f8

Please sign in to comment.