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,6 +85,10 @@ class VLVSearch < Sinatra::Base
85 85
     def signed_in?
86 86
       !!session['user_id']
87 87
     end
88
+
89
+    def external_link(url, text)
90
+      "<a href=\"#{url}\" target=\"_blank\">#{text}</a>"
91
+    end
88 92
   end
89 93
 
90 94
   run! if __FILE__ == $0

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

@@ -2,9 +2,15 @@
2 2
   <p>
3 3
     Made by user reddwarf. This site is a third party product and not officially
4 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 9
     with any questions or suggestions. This site is open source software under
7 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 15
   </p>
10 16
 </footer>

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

@@ -11,9 +11,10 @@
11 11
     <% results.each do |result| %>
12 12
       <div class="results__result <%= params[:type] %>">
13 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 18
           <p class="result__info">
18 19
             <span>
19 20
               created by <%= result[:creator] %>
@@ -28,9 +29,12 @@
28 29
         <% elsif params[:type] == "posts" %>
29 30
           <p>
30 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 38
           </p>
35 39
           <p class="result__info">
36 40
             <%= result[:creator] %> posted this at <%= result[:created_at] %>

Loading…
Cancel
Save