vapid 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/lib/vapid/assets/images/vapid/favicon.ico +0 -0
  4. data/lib/vapid/assets/images/vapid/logo.png +0 -0
  5. data/lib/vapid/assets/images/vapid/logo_inverse.png +0 -0
  6. data/lib/vapid/assets/javascripts/vapid/{admin.coffee → dashboard.coffee} +0 -0
  7. data/lib/vapid/assets/stylesheets/vapid/dashboard.scss +25 -0
  8. data/lib/vapid/assets/stylesheets/vapid/dashboard/_base.scss +36 -0
  9. data/lib/vapid/assets/stylesheets/vapid/dashboard/_fonts.scss +14 -0
  10. data/lib/vapid/assets/stylesheets/vapid/dashboard/_modal.scss +53 -0
  11. data/lib/vapid/assets/stylesheets/vapid/dashboard/_sidebar.scss +22 -0
  12. data/lib/vapid/assets/stylesheets/vapid/dashboard/_variables.scss +6 -0
  13. data/lib/vapid/cli.rb +45 -13
  14. data/lib/vapid/controllers/{admin_controller.rb → dashboard_controller.rb} +60 -64
  15. data/lib/vapid/generator_template/Gemfile.tt +1 -7
  16. data/lib/vapid/generator_template/assets/javascripts/site.js +0 -0
  17. data/lib/vapid/generator_template/assets/stylesheets/site.css +0 -0
  18. data/lib/vapid/generator_template/templates/index.html.erb +84 -24
  19. data/lib/vapid/generator_template/templates/layouts/default.html.erb +3 -14
  20. data/lib/vapid/models/record.rb +22 -0
  21. data/lib/vapid/models/user.rb +7 -2
  22. data/lib/vapid/server.rb +5 -5
  23. data/lib/vapid/version.rb +1 -1
  24. data/lib/vapid/views/{admin → dashboard}/install.html.erb +3 -3
  25. data/lib/vapid/views/{admin → dashboard}/login.html.erb +2 -2
  26. data/lib/vapid/views/dashboard/overview/index.html.erb +3 -0
  27. data/lib/vapid/views/dashboard/records/_form_fields.erb +5 -0
  28. data/lib/vapid/views/dashboard/records/edit.html.erb +10 -0
  29. data/lib/vapid/views/{admin → dashboard}/records/index.html.erb +6 -8
  30. data/lib/vapid/views/dashboard/records/new.html.erb +6 -0
  31. data/lib/vapid/views/dashboard/settings/edit.html.erb +22 -0
  32. data/lib/vapid/views/errors/404.html.erb +4 -1
  33. data/lib/vapid/views/errors/500.html.erb +4 -1
  34. data/lib/vapid/views/layouts/dashboard.html.erb +47 -0
  35. data/lib/vapid/views/layouts/modal.html.erb +21 -0
  36. data/lib/vapid/views/shared/_flash.html.erb +5 -0
  37. metadata +27 -16
  38. data/lib/vapid/assets/stylesheets/vapid/admin.scss +0 -72
  39. data/lib/vapid/generator_template/assets/stylesheets/application.css +0 -120
  40. data/lib/vapid/views/admin/overview/index.html.erb +0 -1
  41. data/lib/vapid/views/admin/records/_form.erb +0 -9
  42. data/lib/vapid/views/admin/records/edit.html.erb +0 -5
  43. data/lib/vapid/views/admin/records/new.html.erb +0 -3
  44. data/lib/vapid/views/layouts/admin.html.erb +0 -41
  45. data/lib/vapid/views/layouts/admin_form.html.erb +0 -22
  46. data/lib/vapid/views/layouts/error.html.erb +0 -11
@@ -4,10 +4,4 @@ gem "vapid", "~> <%= Vapid::VERSION %>"
4
4
 
5
5
  # Vapid supports ActiveRecord, so feel free
6
6
  # to change this to fit your database needs.
7
- group :development, :test do
8
- gem "sqlite3"
9
- end
10
-
11
- group :production do
12
- gem "pg"
13
- end
7
+ gem "sqlite3"
@@ -1,25 +1,85 @@
1
- <div class="hero">
2
- <div class="container">
3
- <h1>Hello, <span vp-text="world"></span></h1>
4
- <div vp-show="world">Nice to meet you, and congrats on getting this set up.</div>
1
+ <!--
2
+ Note: This page is an example only. Feel free to delete everything, and
3
+ start fresh. Also, be sure to checkout the layouts/default template.
4
+ -->
5
+
6
+ <main>
7
+ <div>
8
+ <img src="https://cdn.vapid.com/logo.png" class="logo" alt="Vapid logo" onerror="this.style.display='none'">
9
+ <p>Welcome to Vapid. This is an example page, to help you get started and understand the basics.</p>
10
+ <p>To begin, create two tags anywhere in the HTML of this page:</p>
11
+ <pre><code>&lt;h1 vp-text="title"&gt;&lt;/h1&gt;
12
+ &lt;div vp-richtext="body"&gt;&lt;/div&gt;
13
+ </code></pre>
14
+ <p>The <code>vp-</code> attributes you see tell Vapid two things: 1) what type of content you'd like placed inside of the tag (e.g. <code>vp-richtext</code>); and 2) what you'd like to name the variable (e.g. <code>body</code>).</p>
15
+ <p>Now visit <a href="/dashboard" target="_blank">the dashboard</a> to see how you can edit content.</p>
5
16
  </div>
6
- </div>
7
-
8
- <div class="how container">
9
- <ul>
10
- <li>
11
- <h2>Develop</h2>
12
- <p>Use special HTML attributes, like <code>vp-text</code> and <code>vp-richtext</code> to describe the data model. Group attributes together using <code>vp-group</code>.</p>
13
- </li>
14
- <li>
15
- <h2>Build</h2>
16
- <p>Execute <code>vapid build</code> from the command line, or through your <%= link_to "admin login", "/admin" %>, and see your data model converted into a custom control panel.</p>
17
- </li>
18
- <li>
19
- <h2>Deploy</h2>
20
- <p>Host your content on Vapid's servers using <code>vapid deploy</code>, or on a Rack-compliant server like Heroku.</p>
21
- </li>
22
- </ul>
23
-
24
- <p class="support">And if you get into any trouble, <code>vapid support</code>.</p>
25
- </div>
17
+ </main>
18
+
19
+ <!-- In-page tag for convenience of deleting only. Use assets/stylesheets/site.css for your styles. -->
20
+ <style>
21
+ * {
22
+ padding: 0;
23
+ margin: 0;
24
+ }
25
+
26
+ html, body {
27
+ height: 100%;
28
+ font-family: "Helvetica Neue", Helvetica, sans-serif;
29
+ line-height: 1.33em;
30
+ color: #c3c3c3;
31
+ background: #1b1c1d;
32
+ }
33
+
34
+ a {
35
+ color: white;
36
+ text-decoration: underline;
37
+ }
38
+
39
+ main {
40
+ display: flex;
41
+ height: 100%;
42
+ align-items: center;
43
+ justify-content: center;
44
+ }
45
+
46
+ main div {
47
+ width: 500px;
48
+ max-width: 100%;
49
+ }
50
+
51
+ code {
52
+ display: inline-block;
53
+ background: #333;
54
+ padding: 0 0.25em;
55
+ margin: 0 0.25em;
56
+ vertical-align: bottom;
57
+ }
58
+
59
+ pre > code {
60
+ display: block;
61
+ margin: 2em 0;
62
+ padding: 1em;
63
+ }
64
+
65
+ p {
66
+ margin-bottom: 1em;
67
+ line-height: 1.3em;
68
+ }
69
+
70
+ .logo {
71
+ display: block;
72
+ max-width: 10em;
73
+ margin: 0 auto 3em;
74
+ }
75
+
76
+ @media (max-width: 768px) {
77
+ main div {
78
+ padding: 0 2em;
79
+ }
80
+
81
+ h1 {
82
+ text-align: center;
83
+ }
84
+ }
85
+ </style>
@@ -2,21 +2,10 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>Vapid</title>
5
- <%= stylesheet_link_tag "application" %>
5
+ <%= stylesheet_link_tag "site" %>
6
6
  </head>
7
7
  <body>
8
- <nav>
9
- <div class="container">
10
- <%= link_to "Vapid", "/", class: "vapid" %>
11
-
12
- <ul>
13
- <li><%= link_to "Admin Login", "/admin" %></li>
14
- </ul>
15
- </div>
16
- </nav>
17
-
18
- <main>
19
- <%= yield %>
20
- </main>
8
+ <%= yield %>
9
+ <%= javascript_include_tag "site" %>
21
10
  </body>
22
11
  </html>
@@ -25,6 +25,28 @@ module Vapid
25
25
  def content_summary
26
26
  group.text_fields.any? ? content.values_at(*group.text_fields).join(", ") : content.to_json
27
27
  end
28
+
29
+ def update_content(content, remove = {})
30
+ content.each do |key, val|
31
+ # TODO: File uploads?
32
+ # if val.is_a?(Hash) && val[:tempfile]
33
+ # FileUtils.mkdir_p(settings.project_uploads)
34
+ # File.open File.join(settings.project_uploads, val[:filename]), "wb" do |file|
35
+ # file.write val[:tempfile].read
36
+ # end
37
+ # val = "/uploads/#{val[:filename]}"
38
+ # end
39
+
40
+ content_type = group.fields[key]
41
+ self.content[key] = Directives[content_type].serialize_input(val)
42
+ end
43
+
44
+ remove.each do |key, _val|
45
+ self.content[key] = nil
46
+ end if remove
47
+
48
+ save
49
+ end
28
50
  end
29
51
  end
30
52
  end
@@ -4,8 +4,13 @@ module Vapid
4
4
  class User < ActiveRecord::Base
5
5
  has_secure_password
6
6
 
7
- validates :email, presence: true, uniqueness: { case_sensitive: false, message: "is already taken" }
8
- validates :password, presence: true, length: { within: 6..42 }
7
+ validates :email,
8
+ presence: true,
9
+ format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i },
10
+ uniqueness: { case_sensitive: false, message: "is already taken" }
11
+ validates :password,
12
+ length: { minimum: 6 },
13
+ allow_nil: false
9
14
 
10
15
  def self.authenticate(email, password)
11
16
  user = find_by("lower(email) = ?", email.downcase)
@@ -9,7 +9,7 @@ require "sass"
9
9
  require "sprockets"
10
10
  require "uglifier"
11
11
  require "rack-livereload"
12
- require_relative "controllers/admin_controller"
12
+ require_relative "controllers/dashboard_controller"
13
13
  require_relative "controllers/project_controller"
14
14
 
15
15
  module Vapid
@@ -52,7 +52,7 @@ module Vapid
52
52
  configure :development do
53
53
  set :show_exceptions, :after_handler
54
54
  use Rack::LiveReload, no_swf: true,
55
- ignore: [%r{^/(admin|auth)}]
55
+ ignore: [%r{^/(dashboard)}]
56
56
  FileUtils.touch settings.reload
57
57
  end
58
58
 
@@ -76,19 +76,19 @@ module Vapid
76
76
 
77
77
  error Padrino::Rendering::TemplateNotFound do
78
78
  status 404
79
- render "errors/404", layout: :error
79
+ render "errors/404", layout: :modal
80
80
  end
81
81
 
82
82
  error do
83
83
  status 500
84
- render "errors/500", layout: :error
84
+ render "errors/500", layout: :modal
85
85
  end
86
86
 
87
87
  register Sinatra::Flash
88
88
  register Sinatra::Namespace
89
89
  register Padrino::Helpers
90
90
 
91
- register Controllers::AdminController
91
+ register Controllers::DashboardController
92
92
  register Controllers::ProjectController
93
93
  end
94
94
  end
@@ -1,4 +1,4 @@
1
1
  # Version
2
2
  module Vapid
3
- VERSION = "0.1.1".freeze
3
+ VERSION = "0.1.2".freeze
4
4
  end
@@ -1,6 +1,6 @@
1
- <% form_tag "", class: "ui large form" do |f| %>
1
+ <% form_tag "", class: "ui form" do |f| %>
2
2
  <div class="field">
3
- <p>Welcome. Before we get started, we need to create an admin account for you.</p>
3
+ <p>Before we get started, we need to create a dashboard login account for you.</p>
4
4
  <p>Check to make sure your <code>config/database.yml</code> settings are correct, and then fill out the form below:</p>
5
5
  </div>
6
6
  <div class="field">
@@ -15,5 +15,5 @@
15
15
  <%= text_field_tag :code, value: params[:code], placeholder: "Install code (found in config/settings.yml)" if @code %>
16
16
  </div>
17
17
 
18
- <%= submit_tag "Create Admin Account", class: "ui fluid large submit button" %>
18
+ <%= submit_tag "Create Login", class: "ui fluid button" %>
19
19
  <% end %>
@@ -1,4 +1,4 @@
1
- <% form_for @user, "", class: "ui large form" do |f| %>
1
+ <% form_for @user, "", class: "ui form" do |f| %>
2
2
  <div class="field">
3
3
  <%= f.email_field :email, placeholder: "Email" %>
4
4
  </div>
@@ -7,5 +7,5 @@
7
7
  <%= f.password_field :password, placeholder: "Password" %>
8
8
  </div>
9
9
 
10
- <%= f.submit "Submit", class: "ui fluid large submit button" %>
10
+ <%= f.submit "Log in", class: "ui fluid button" %>
11
11
  <% end %>
@@ -0,0 +1,3 @@
1
+ <h1>Overview</h1>
2
+
3
+ <p>Right now, there's nothing on this dashboard homepage, but please check back soon. Who knows, one day there might be something slightly more than nothing.</p>
@@ -0,0 +1,5 @@
1
+ <% @record.group.fields.each do |field, type| %>
2
+ <div class="field">
3
+ <%= f.vp_field field, type, @record.content[field] %>
4
+ </div>
5
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <h1>Edit <%= @group.display_name.singularize %></h1>
2
+
3
+ <% record_form_for @record, "/dashboard/groups/#{@group.id}/records/#{@record.id}", multipart: true, class: "ui form" do |f| %>
4
+ <%= dashboard_partial "records/form_fields", locals: { f: f } %>
5
+ <%= f.submit "Update #{@group.display_name.singularize}", class: "ui button" %>
6
+ <% end %>
7
+
8
+ <p>
9
+ <%= button_to "Delete #{@group.display_name.singularize}", "/dashboard/groups/#{@group.id}/records/#{@record.id}", method: :delete, data: { delete: true, confirm: "Are you sure you want to delete this #{@record.group.display_name.singularize.downcase}?" } if @group.repeating? %>
10
+ </p>
@@ -1,10 +1,8 @@
1
- <h1><%= @group.display_name %></h1>
2
-
3
- <p>
4
- <% link_to "/admin/groups/#{@group.id}/records/new", class: "ui primary small button" do %>
5
- <i class="icon plus"></i><%= "New #{@group.display_name.singularize}" %>
6
- <% end %>
7
- </p>
1
+ <div class="ui basic clearing vertical segment header-group">
2
+ <h1 class="ui left floated header"><%= @group.display_name %></h1>
3
+
4
+ <%= link_to "New #{@group.display_name.singularize}", "/dashboard/groups/#{@group.id}/records/new", class: "ui right floated small button" %>
5
+ </div>
8
6
 
9
7
  <table class="ui single line table">
10
8
  <thead>
@@ -28,7 +26,7 @@
28
26
  <td><%= record.content_summary %></td>
29
27
  <% end %>
30
28
  <td class="right aligned">
31
- <% link_to "/admin/groups/#{@group.id}/records/#{record.id}/edit" do %>
29
+ <% link_to "/dashboard/groups/#{@group.id}/records/#{record.id}/edit" do %>
32
30
  <i class="icon edit"></i>Edit
33
31
  <% end %>
34
32
  </td>
@@ -0,0 +1,6 @@
1
+ <h1><%= @group.repeating? ? "New #{@group.display_name}" : @group.display_name %></h1>
2
+
3
+ <% record_form_for @record, "/dashboard/groups/#{@group.id}/records", multipart: true, class: "ui form" do |f| %>
4
+ <%= dashboard_partial "records/form_fields", locals: { f: f } %>
5
+ <%= f.submit "Create New #{@group.display_name.singularize}", class: "ui button" %>
6
+ <% end %>
@@ -0,0 +1,22 @@
1
+ <h1>Edit Your Account</h1>
2
+
3
+ <form method="POST" class="ui form">
4
+ <div class="field">
5
+ <label>Email</label>
6
+ <input type="email" name="email" value="<%= current_user.email %>">
7
+ </div>
8
+
9
+ <div class="field">
10
+ <label>New Password</label>
11
+ <input type="password" name="password">
12
+ </div>
13
+
14
+ <div class="field">
15
+ <label>Confirm New Password</label>
16
+ <input type="password" name="password_confirmation" autocomplete="off">
17
+ </div>
18
+
19
+ <div class="field">
20
+ <input type="submit" class="ui button" value="Update Settings">
21
+ </div>
22
+ </form>
@@ -1 +1,4 @@
1
- <h1>Page Not Found</h1>
1
+ <div style="text-align: center">
2
+ <h2>Page not found</h2>
3
+ <p>Sorry, the page you were looking for could not be found. Please go <%= link_to "home", "/" %>, or contact support.</p>
4
+ </div>
@@ -1 +1,4 @@
1
- <h1>Error</h1>
1
+ <div style="text-align: center">
2
+ <h2>Something went wrong</h2>
3
+ <p>Sorry, an error occurred while you were visiting this page. Please try again, or contact support.</p>
4
+ </div>
@@ -0,0 +1,47 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Vapid</title>
5
+ <%= stylesheet_link_tag "vapid/dashboard" %>
6
+ <%= javascript_include_tag "vapid/dashboard" %>
7
+ <%= favicon_tag "vapid/favicon.ico" %>
8
+ <%= csrf_meta_tags %>
9
+ </head>
10
+ <body class="dashboard">
11
+ <div class="ui bottom attached segment pushable">
12
+ <div class="ui visible inverted left vertical sidebar menu">
13
+ <div class="item">
14
+ <% link_to "/dashboard" do %>
15
+ <%= image_tag "vapid/logo.png", class: "logo", alt: "Vapid logo" %>
16
+ <% end %>
17
+ </div>
18
+
19
+ <div class="item">
20
+ <div class="header">Content</div>
21
+ <div class="menu">
22
+ <% @groups.each do |group| %>
23
+ <%= link_to group.display_name, group_or_records_path(group), class: "item" %>
24
+ <% end %>
25
+ </div>
26
+ </div>
27
+
28
+ <div class="item">
29
+ <div class="header">Settings</div>
30
+ <div class="menu">
31
+ <%= link_to "Build Site", "/dashboard/build", class: "item" %>
32
+ <%= link_to "Edit Account", "/dashboard/settings", class: "item" %>
33
+ <%= link_to "Log out", "/dashboard/logout", class: "item" %>
34
+ </div>
35
+ </div>
36
+ </div>
37
+
38
+ <div class="pusher">
39
+ <main class="ui basic segment">
40
+ <%= partial "shared/flash" %>
41
+
42
+ <%= yield %>
43
+ </main>
44
+ </div>
45
+ </div>
46
+ </body>
47
+ </html>
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Vapid</title>
5
+ <%= stylesheet_link_tag "vapid/dashboard" %>
6
+ <%= csrf_meta_tags %>
7
+ </head>
8
+ <body class="modal">
9
+ <div class="ui middle aligned center aligned grid">
10
+ <div class="column">
11
+ <%= image_tag "vapid/logo_inverse.png", class: "logo", alt: "Vapid logo" %>
12
+
13
+ <div class="ui left aligned basic padded segment">
14
+ <%= partial "shared/flash" %>
15
+
16
+ <%= yield %>
17
+ </div>
18
+ </div>
19
+ </div>
20
+ </body>
21
+ </html>
@@ -0,0 +1,5 @@
1
+ <% content_tag :div, id: "flash" do %>
2
+ <% flash.each do |key, value| %>
3
+ <%= content_tag :div, value, class: "ui message #{flash_class(key)}" unless value.blank? %>
4
+ <% end %>
5
+ <% end if flash.any? %>