-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create command line for new template (#16)
- Loading branch information
Showing
5 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ | |
examples/*.sqlite* | ||
**/*.sqlite* | ||
log/* | ||
**/uni_rails.gem | ||
**/uni_rails.gem | ||
.byebug_history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
uni_rails (0.3.0) | ||
uni_rails (0.4.0) | ||
rackup (~> 2.1) | ||
rails (~> 7.1) | ||
turbo-rails (~> 2.0) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
ENV["SECRET_KEY_BASE"] = "1212312313" | ||
ENV["DATABASE_URL"] = "sqlite3:///#{__dir__}/database.sqlite" | ||
|
||
require "bundler/inline" | ||
|
||
gemfile do | ||
source "https://www.rubygems.org" | ||
gem "uni_rails" | ||
gem "sqlite3", "~> 1.7" | ||
gem "byebug" | ||
end | ||
|
||
require "uni_rails" | ||
require "sqlite3" | ||
require "byebug" | ||
|
||
# ==== ROUTES ==== | ||
UniRails::App.routes.append do | ||
root "resource_names#new" | ||
resources :resource_names | ||
end | ||
|
||
# ==== DB SCHEMA ==== | ||
ActiveRecord::Base.establish_connection | ||
ActiveRecord::Schema.define do | ||
create_table :resources, force: :cascade do |t| | ||
t.string :title | ||
end | ||
end | ||
|
||
# ==== MODELS ==== | ||
class Resource < ActiveRecord::Base | ||
end | ||
|
||
# ==== SEEDS ==== | ||
# Create your existing records here | ||
|
||
# ==== CONTROLLERS ==== | ||
class ResourceNamesController < ActionController::Base | ||
layout 'application' | ||
|
||
def new | ||
end | ||
|
||
def create | ||
end | ||
end | ||
|
||
# ==== IMPORT MAPS ==== | ||
UniRails.import_maps( | ||
'stimulus' => 'https://unpkg.com/@hotwired/stimulus/dist/stimulus.js' | ||
) | ||
|
||
|
||
# ==== JAVASCRTIP ==== | ||
UniRails.javascript <<~JAVASCRIPT | ||
import { Application, Controller } from "stimulus" | ||
window.Stimulus = Application.start() | ||
|
||
Stimulus.register("hello", class extends Controller { | ||
connect() { | ||
console.log("hello world") | ||
} | ||
}) | ||
|
||
JAVASCRIPT | ||
|
||
# ==== CSS ==== | ||
UniRails.css <<~CSS | ||
html { background-color:#EEE; } | ||
body { width:500px; height:700px; margin:auto; | ||
background-color:white; padding:1rem; | ||
} | ||
form { | ||
label { display: block; } | ||
input[type="submit"] { display: block; margin-top:1rem; } | ||
.field_with_errors { color:red; display:inline; } | ||
} | ||
CSS | ||
|
||
# ==== VIEWS ==== | ||
UniRails.register_view "resource_names/new.html.erb", <<~HTML | ||
HTML | ||
|
||
UniRails.register_view "resource_names/show.html.erb", <<~HTML | ||
HTML | ||
|
||
UniRails.run(Port: 3000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env ruby | ||
|
||
# require "byebug" | ||
# byebug | ||
|
||
assets_path = File.expand_path('../assets', __dir__) | ||
|
||
options = {} | ||
case ARGV[0] | ||
when "new" | ||
filename = ARGV[1] | ||
File.open(filename, 'wb+') do |f| | ||
f.write File.read File.join(assets_path, 'templates', 'default.txt') | ||
end | ||
else | ||
puts "unknown command" | ||
puts "Usage: unirails new <filename>" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module UniRails | ||
VERSION = "0.3.0" | ||
VERSION = "0.4.0" | ||
end |