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

Roda example #100

Merged
merged 2 commits into from
Nov 8, 2023
Merged
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
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>