8 Commits

Author SHA1 Message Date
  Dylan Baker 3060aaa9e2 Better mobile form styles 2 years ago
  Dylan Baker 5b47d8f53f Add gemset to ruby version file 2 years ago
  Dylan Baker f257672254 Add rake task to run the server 2 years ago
  Dylan Baker b18667d5ca Create public folder if it doesn't exist already 2 years ago
  Dylan Baker 0a58dd5c89 Raise if auth is unsuccessful 2 years ago
  Dylan Baker 78aa0e6049 Add example env file 2 years ago
  Dylan Baker cb06b47bad Move requires into the relevant tasks 2 years ago
  Dylan Baker adbcd7e675 Add ruby-version 2 years ago
6 changed files with 49 additions and 7 deletions
  1. 10
    0
      .env.example
  2. 1
    0
      .ruby-version
  3. 16
    3
      Rakefile
  4. 10
    1
      db/scrape.rb
  5. 12
    1
      web/assets/styles/form.scss
  6. 0
    2
      web/server.rb

+ 10
- 0
.env.example View File

@@ -0,0 +1,10 @@
1
+DB_DATABASE=
2
+DB_USERNAME=
3
+DB_PASSWORD=
4
+PROD_USERNAME=
5
+PROD_HOSTNAME=
6
+VLV_USERNAME=
7
+VLV_PASSWORD=
8
+SESSION_KEY=
9
+SESSION_DOMAIN=
10
+SESSION_SECRET=

+ 1
- 0
.ruby-version View File

@@ -0,0 +1 @@
1
+2.6.3@vlv-search

+ 16
- 3
Rakefile View File

@@ -1,20 +1,33 @@
1 1
 require 'dotenv/load'
2
-require 'sassc'
3 2
 
4
-require_relative './db/migrate'
5
-require_relative './db/scrape'
3
+task 'server' do
4
+  require_relative './web/server'
5
+
6
+  VLVSearch.run!
7
+end
6 8
 
7 9
 task 'migrate' do
10
+  require_relative './db/migrate'
11
+
8 12
   migrate
9 13
 end
10 14
 
11 15
 task 'scrape' do
16
+  require_relative './db/scrape'
17
+
12 18
   should_log = ENV['APP_ENV'] == 'development' || ARGV.include?('--log')
13 19
   scraper = Scraper.new(log: should_log)
14 20
   scraper.scrape
15 21
 end
16 22
 
17 23
 task 'build' do
24
+  require 'sassc'
25
+
26
+  unless Dir.exist?('./web/public')
27
+    puts 'Creating web/public/'
28
+    Dir.mkdir('./web/public')
29
+  end
30
+
18 31
   scss = File.read('./web/assets/style.scss')
19 32
   css = SassC::Engine.new(scss, style: :compressed).render
20 33
   puts 'Writing web/public/style.css'

+ 10
- 1
db/scrape.rb View File

@@ -13,7 +13,8 @@ class Scraper
13 13
     @first = first
14 14
     @last = last
15 15
     @log = log
16
-    @cookie = login(ENV['VLV_USERNAME'], ENV['VLV_PASSWORD'])
16
+
17
+    authenticate!
17 18
   end
18 19
 
19 20
   def scrape
@@ -32,6 +33,14 @@ class Scraper
32 33
     end
33 34
   end
34 35
 
36
+  private
37
+
38
+  def authenticate!
39
+    @cookie = login(ENV['VLV_USERNAME'], ENV['VLV_PASSWORD'])
40
+
41
+    raise "Error logging into VLV. Check your credentials." if @cookie.nil?
42
+  end
43
+
35 44
   def scrape_thread(t)
36 45
     log t[:title]
37 46
 

+ 12
- 1
web/assets/styles/form.scss View File

@@ -20,6 +20,10 @@
20 20
 .filters__section {
21 21
   display: flex;
22 22
   padding: .5em 0;
23
+
24
+  @media(max-width: 768px) {
25
+    flex-direction: column;
26
+  }
23 27
 }
24 28
 
25 29
 .filters__subsection--sort {
@@ -32,11 +36,18 @@
32 36
 
33 37
 .filters__subsection {
34 38
   flex: 1;
35
-  padding: 0 1em;
36 39
 
37 40
   &.filters__subsection--static {
38 41
     flex: 1;
39 42
   }
43
+
44
+  &:nth-child(2) {
45
+    padding: 0 1em;
46
+
47
+    @media(max-width: 768px) {
48
+      padding: 0;
49
+    }
50
+  }
40 51
 }
41 52
 
42 53
 .form__field {

+ 0
- 2
web/server.rb View File

@@ -128,6 +128,4 @@ class VLVSearch < Sinatra::Base
128 128
       Truncato.truncate(s, max_length: 500)
129 129
     end
130 130
   end
131
-
132
-  run! if __FILE__ == $0
133 131
 end

Loading…
Cancel
Save