Browse Source

Add external_link helper

master
Dylan Baker 4 years ago
parent
commit
dbf5c32bdd
3 changed files with 22 additions and 8 deletions
  1. 4
    0
      web/server.rb
  2. 8
    2
      web/views/partials/footer.erb
  3. 10
    6
      web/views/results.erb

+ 4
- 0
web/server.rb View File

85
     def signed_in?
85
     def signed_in?
86
       !!session['user_id']
86
       !!session['user_id']
87
     end
87
     end
88
+
89
+    def external_link(url, text)
90
+      "<a href=\"#{url}\" target=\"_blank\">#{text}</a>"
91
+    end
88
   end
92
   end
89
 
93
 
90
   run! if __FILE__ == $0
94
   run! if __FILE__ == $0

+ 8
- 2
web/views/partials/footer.erb View File

2
   <p>
2
   <p>
3
     Made by user reddwarf. This site is a third party product and not officially
3
     Made by user reddwarf. This site is a third party product and not officially
4
     associated with VLV. Feel free to
4
     associated with VLV. Feel free to
5
-    <a href="http://board.vivalavinyl.com/message/create/reddwarf/">PM me</a>
5
+    <%= external_link(
6
+      'http://board.vivalavinyl.com/message/create/reddwarf',
7
+      'PM me'
8
+    ) %>
6
     with any questions or suggestions. This site is open source software under
9
     with any questions or suggestions. This site is open source software under
7
     the terms of the MIT license and the code can be found
10
     the terms of the MIT license and the code can be found
8
-    <a href="https://git.simulacrum.party/simulacrumparty/vlv-search">here</a>.
11
+    <%= external_link(
12
+      'https://git.simulacrum.party/simulacrumparty/vlv-search',
13
+      'here'
14
+    ) %>.
9
   </p>
15
   </p>
10
 </footer>
16
 </footer>

+ 10
- 6
web/views/results.erb View File

11
     <% results.each do |result| %>
11
     <% results.each do |result| %>
12
       <div class="results__result <%= params[:type] %>">
12
       <div class="results__result <%= params[:type] %>">
13
         <% if params[:type] == "threads" %>
13
         <% if params[:type] == "threads" %>
14
-          <a href="http://board.vivalavinyl.com/thread/view/<%= result[:remote_id] %>">
15
-            <%= result[:title] %>
16
-          </a>
14
+          <%= external_link(
15
+            "http://board.vivalavinyl.com/thread/view/#{result[:remote_id]}",
16
+            result[:title]
17
+          ) %>
17
           <p class="result__info">
18
           <p class="result__info">
18
             <span>
19
             <span>
19
               created by <%= result[:creator] %>
20
               created by <%= result[:creator] %>
28
         <% elsif params[:type] == "posts" %>
29
         <% elsif params[:type] == "posts" %>
29
           <p>
30
           <p>
30
             In thread:
31
             In thread:
31
-            <a href="http://board.vivalavinyl.com/thread/view/<%= result[:remote_thread_id] %>">
32
-              <strong><%= result[:thread_title] %></strong>
33
-            </a>
32
+            <strong>
33
+              <%= external_link(
34
+                "http://board.vivalavinyl.com/thread/view/#{result[:remote_thread_id]}",
35
+                result[:thread_title]
36
+              ) %>
37
+            </strong>
34
           </p>
38
           </p>
35
           <p class="result__info">
39
           <p class="result__info">
36
             <%= result[:creator] %> posted this at <%= result[:created_at] %>
40
             <%= result[:creator] %> posted this at <%= result[:created_at] %>

Loading…
Cancel
Save