Class: Nwiki::Frontend::Top

Inherits:
Object
  • Object
show all
Defined in:
lib/nwiki/frontend/app/top.rb

Instance Method Summary collapse

Constructor Details

#initialize(git_repo_path, opts = {}) ⇒ Top

Returns a new instance of Top.



7
8
9
# File 'lib/nwiki/frontend/app/top.rb', line 7

def initialize git_repo_path, opts = {}
  @wiki = Nwiki::Core::Wiki.new git_repo_path
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/nwiki/frontend/app/top.rb', line 11

def call env
  [
    200,
    { "Content-Type" => "text/html; charset=#{Nwiki::Core::Wiki.repo_filename_encoding}" },
    [html]
  ]
end

#htmlObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/nwiki/frontend/app/top.rb', line 19

def html
  erb = ERB.new <<EOS
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="refresh" content="5;URL=http://niku.name/articles/">
  <title><%= @wiki.title %></title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="alternate" type="application/atom+xml" title="ATOM Feed" href="/articles.xml">
  <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
  <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
</head>
<body>
  <a href="https://github.com/niku/nikulog">
    <img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png" alt="Fork me on GitHub">
  </a>
  <div class="container">
    <div class="row">
<div class="col-md-8"><h1><a href="/articles/"><%= @wiki.title %></a></h1></div>
    </div>
    <div class="row">
<div class="col-md-12"><h2"><small><%= @wiki.subtitle %></small></h2></div>
    </div>
    <div class="row">
<div class="col-md-12">
  <p>ここまだ何にも作ってないんす.<a href="./articles/">articles</a>以下が動いているのでそっちを見てね.5秒経つと自動で移動します.</p>
</div>
    </div>
  </div>
  <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  <script src="//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</body>
</html>
EOS
  erb.result(binding).force_encoding(Nwiki::Core::Wiki.repo_filename_encoding)
end