aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/guff/views/ecrs/test/auth.ecr15
-rw-r--r--src/guff/views/html/test/auth.cr40
2 files changed, 48 insertions, 7 deletions
diff --git a/src/guff/views/ecrs/test/auth.ecr b/src/guff/views/ecrs/test/auth.ecr
index 6cfb3d4..4c032ec 100644
--- a/src/guff/views/ecrs/test/auth.ecr
+++ b/src/guff/views/ecrs/test/auth.ecr
@@ -1,4 +1,7 @@
-<div class='navbar navbar-default' role='navigation'>
+<div
+ class='navbar navbar-inverse navbar-static-top'
+ role='navigation'
+>
<div class='container-fluid'>
<div class='navbar-header'>
<a
@@ -16,16 +19,14 @@
<div class='panel panel-default'>
<div class='panel-heading'>
<b>
- <i class='fa fa-search'></i>
+ <i class='fa fa-users'></i>
Auth Test
</b>
</div><!-- panel-heading -->
- <div class='panel-body'>
- <p>
- Auth test.
- </p>
- </div><!-- panel-body -->
+ <div class='list-group'><%=
+ users
+ %></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 bdada74..b21ebf6 100644
--- a/src/guff/views/html/test/auth.cr
+++ b/src/guff/views/html/test/auth.cr
@@ -5,6 +5,37 @@ 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",
+ }]
+
def self.run(models, context : HTTP::Server::Context)
new(models).run(context)
end
@@ -19,6 +50,15 @@ class Guff::TestAuthHTMLView
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