Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Nicklas committed Jun 11, 2018
0 parents commit 95c23c3
Show file tree
Hide file tree
Showing 14 changed files with 242 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

######################################################################
#
# Ignore Vim files
# https://github.com/github/gitignore/blob/master/Global/Vim.gitignore
#
######################################################################

# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]

# Session
Session.vim

# Temporary
.netrwhist
*~
# Auto-generated tag files
tags

######################################################################

# Ignore bundler config and gems.
/.bundle
/vendor/bundle

# Ignore all logfiles and tempfiles.
/log/*
!/log/.keep
/tmp/*
!/tmp/.keep
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source "https://rubygems.org"

gem "sinatra", "~> 2.0"
gem "erubi", "~> 1.7"
gem "auto_reloader", "~> 0.4"

gem "pry", :group => :development
29 changes: 29 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
GEM
remote: https://rubygems.org/
specs:
auto_reloader (0.4.1)
coderay (1.1.2)
erubi (1.7.1)
method_source (0.9.0)
mustermann (1.0.2)
pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
rack (2.0.5)
rack-protection (2.0.3)
rack
sinatra (2.0.3)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.3)
tilt (~> 2.0)
tilt (2.0.8)

PLATFORMS
ruby

DEPENDENCIES
auto_reloader (~> 0.4)
erubi (~> 1.7)
pry
sinatra (~> 2.0)
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018 <COPYRIGHT HOLDER>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Base Sinatra App for Summer Institute 2018

![GitHub Release](https://img.shields.io/github/release/osc/ood-example-ps.svg)
[![GitHub License](https://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT)

This app is meant as a base Passenger app that runs in an [OnDemand] portal
that uses the [Sinatra] web framework. Feel free to modify it anyway you see
fit.

## Deploy

The directions below require Ruby and Bundler be installed and accessible from
the command line. If using a machine that has [Software Collections] you may
want to run the following command beforehand:

```console
$ source scl_source rh-ruby22 git19
```

Feel free to replace `rh-ruby22` and `git19` with whatever installation your
site uses through Software Collections.

1. To deploy and run this app you will need to first go to your OnDemand
sandbox directory (if it doesn't exist, then we create it):

```console
$ mkdir -p ~/ondemand/dev
$ cd ~/ondemand/dev
```

2. Then clone down this app and `cd` into it:

```console
$ git clone [email protected]:OSC/si-18-sinatra-base.git my_app
Cloning into 'my_app'...
$ cd my_app
```

3. Setup the app before you use it:

```console
$ bin/setup

...
```

4. Now you should be able to access this app from OSC OnDemand at
https://ondemand.osc.edu/pun/dev/my_app/

Note: You may need to replace the domain above with your center's OnDemand
portal location if not using OSC.

[OnDemand]: http://openondemand.org/
[Sinatra]: http://sinatrarb.com/
[Software Collections]: https://www.softwarecollections.org/en/
13 changes: 13 additions & 0 deletions app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require "sinatra/base"

class App < Sinatra::Base
set :erb, :escape_html => true

def title
"My App"
end

get "/" do
erb :index
end
end
6 changes: 6 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env ruby

require "bundler/setup"

require "pry"
Pry.start
8 changes: 8 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx

bundle install --path=vendor/bundle

# Do any other automated setup that you need to do here
13 changes: 13 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
if ENV["RACK_ENV"] != "development"
require_relative "app"
run App
else
require "auto_reloader"
AutoReloader.activate reloadable_paths: [__dir__], delay: 1
run ->(env) {
AutoReloader.reload! do |unloaded|
require_relative "app"
App.call env
end
}
end
4 changes: 4 additions & 0 deletions manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: My App
icon: fa://gear
description: |
My first OnDemand app.
Empty file added public/.keep
Empty file.
Empty file added tmp/.keep
Empty file.
5 changes: 5 additions & 0 deletions views/index.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1 class="display-4 py-3 mb-3 border-bottom">
<%= title %>
</h1>

Hello world!
42 changes: 42 additions & 0 deletions views/layout.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!doctype html>

<html lang="en">
<head>
<meta charset="utf-8">

<title><%= title %></title>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</head>
<body>

<header>
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
<a href="/" class="navbar-brand"><%= ENV["ONDEMAND_TITLE"] %></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a href="<%= url("/") %>" class="nav-link">
<i class="fas fa-home"></i> <%= title %>
</a>
</li>
</ul>
</div>
</nav>
</header>

<div class="container" role="main">
<%== yield %>
</div>

</body>
</html>

0 comments on commit 95c23c3

Please sign in to comment.