aboutsummaryrefslogtreecommitdiff
path: root/src/guff/views
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-03-14 02:20:50 -0400
committerPaul Duncan <pabs@pablotron.org>2016-03-14 02:20:50 -0400
commitcf90fa002afec60e2c057348de24ca1d8bcbaaa4 (patch)
tree574b1df80a060a56946f45309956f3d63bbcfabe /src/guff/views
parente88219d9a4bbc85563a2ead6708641de389af4fa (diff)
downloadold-guff-cf90fa002afec60e2c057348de24ca1d8bcbaaa4.tar.bz2
old-guff-cf90fa002afec60e2c057348de24ca1d8bcbaaa4.zip
add test/{get_users,set_user}, js/util.js, lots more
Diffstat (limited to 'src/guff/views')
-rw-r--r--src/guff/views/ecrs/test/auth.ecr26
-rw-r--r--src/guff/views/html/test/auth.cr43
2 files changed, 24 insertions, 45 deletions
diff --git a/src/guff/views/ecrs/test/auth.ecr b/src/guff/views/ecrs/test/auth.ecr
index 4c032ec..c28f178 100644
--- a/src/guff/views/ecrs/test/auth.ecr
+++ b/src/guff/views/ecrs/test/auth.ecr
@@ -20,13 +20,31 @@
<div class='panel-heading'>
<b>
<i class='fa fa-users'></i>
- Auth Test
+ Users
</b>
+
+ <a
+ href='#'
+ id='reload'
+ class='btn btn-default btn-xs pull-right'
+ title='Reload users.'
+ >
+ <span class='loading'>
+ <i class='fa fa-refresh'></i>
+ </span>
+
+ <span class='loading hidden'>
+ <i class='fa fa-spinner fa-spin'></i>
+ </span>
+ </a><!-- #reload -->
</div><!-- panel-heading -->
- <div class='list-group'><%=
- users
- %></div><!-- list-group -->
+ <div id='users' class='list-group'>
+ <span class='list-group-item disabled'>
+ <i class='fa fa-spinner fa-spin'></i>
+ Loading...
+ </span><!-- list-group-item -->
+ </div><!-- list-group -->
</div><!-- panel -->
</div><!-- col-md-8 -->
</div><!-- container -->
diff --git a/src/guff/views/html/test/auth.cr b/src/guff/views/html/test/auth.cr
index b21ebf6..9f5d1ad 100644
--- a/src/guff/views/html/test/auth.cr
+++ b/src/guff/views/html/test/auth.cr
@@ -3,38 +3,7 @@ require "../page"
class Guff::TestAuthHTMLView
TITLE = "Guff Auth Test"
- FEATURES = %w{bootstrap font-awesome}
-
- TEMPLATES = TemplateCache.new({
- user: "<a
- href='#'
- class='list-group-item %{css}'
- title='Set user to \"%{name}.\"'
- data-user_id='%{id}'
- >%{name}</a>"
- })
-
- MOCK_USERS = [{
- "id": "0",
- "name": "Guest",
- "active": "1",
- }, {
- "id": "1",
- "name": "Admin",
- "active": "0",
- }, {
- "id": "2",
- "name": "Test User 1",
- "active": "0",
- }, {
- "id": "2",
- "name": "Test User 2",
- "active": "0",
- }, {
- "id": "3",
- "name": "Test User<<<<>>>>>&&&&&&2",
- "active": "0",
- }]
+ FEATURES = %w{bootstrap font-awesome guff/util}
def self.run(models, context : HTTP::Server::Context)
new(models).run(context)
@@ -46,19 +15,11 @@ class Guff::TestAuthHTMLView
def run(context)
page = PageHTMLView.new(TITLE, self.to_s)
page.add_features(FEATURES)
+ page.scripts << "/guff-stuff/test/auth.js"
context.response.content_type = page.content_type
context.response.puts page
end
- def users
- MOCK_USERS.map { |row|
- TEMPLATES[:user].run(row.merge({
- "name": h(row["name"]),
- "css": (row["active"] == "1") ? "active" : "",
- }))
- }.join("")
- end
-
def h(s : String)
HTML.escape(s || "")
end