litestream_rails 0.3.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e9c8bcec979cf18668f44388864b49c3111ed8be9025cc16e8dde054ef2281a
4
- data.tar.gz: b747117ff97159c50a17b87b1ad7bfdcbb2f1c0503195ff63e7c1c85ea66f9f0
3
+ metadata.gz: 0f7bd823a8640fa5b07a03af03d576eb4349e2b88c1c70cad211fc58bc927bc3
4
+ data.tar.gz: 1ddebc7f7a08d7f8a2097a1aaabbe862f88d147468065e3334d4c98af7963886
5
5
  SHA512:
6
- metadata.gz: ded52a5d85703cb8a3f573ccfdb98a267e2db042f82a66db25afcfe703d7dca08e1feb161bb6e1a08fbab2de6134a08f44964ff69f01e400f289a31c87714230
7
- data.tar.gz: 3a6e1933b8ce9cf878dc73564c923fe36ec5bb69ee17685f13700b7561532134efce2809b604027f22c3f945f611aea1cabbfb5e0c07b07104fe3ec68dcb12d1
6
+ metadata.gz: 10c34abb1f12c8a1e9ef75b748e4e6fcd3684ef0e3044e36847fe3c44bcc0c831c61ce4ac0cdc275f8afd12b16540b54177f12fd1610a603b9d3668d964411c9
7
+ data.tar.gz: 6302e48d4eda7c817152903bd3536f14cd322976615ed85c8b95e47f0d8034f5580e0fabc3601b290d29c51fcf82187fe18269214e396f1fd168f2efed1dab4e
@@ -0,0 +1,17 @@
1
+ module LitestreamRails
2
+ class RestorationsController < ApplicationController
3
+ # POST /restorations
4
+ def create
5
+ database = params[:database].remove("[ROOT]/")
6
+ dir, file = File.split(database)
7
+ ext = File.extname(file)
8
+ base = File.basename(file, ext)
9
+ now = Time.now.utc.strftime("%Y%m%d%H%M%S")
10
+ backup = File.join(dir, "#{base}-#{now}#{ext}")
11
+
12
+ Litestream::Commands.restore(database, async: false, **{"-o" => backup})
13
+
14
+ redirect_to root_path, notice: "Restored to <code>#{backup}</code>."
15
+ end
16
+ end
17
+ end
@@ -544,6 +544,9 @@
544
544
  .inline-flex {
545
545
  display: inline-flex;
546
546
  }
547
+ .inline-block {
548
+ display: inline-block;
549
+ }
547
550
  .table {
548
551
  display: table;
549
552
  }
@@ -621,12 +624,23 @@
621
624
  .rounded-md {
622
625
  border-radius: 0.375rem;
623
626
  }
627
+ .rounded-lg {
628
+ border-radius: 0.5rem;
629
+ }
624
630
  .border-b {
625
631
  border-bottom-width: 1px;
626
632
  }
627
633
  .border-t {
628
634
  border-top-width: 1px;
629
635
  }
636
+ .bg-green-50 {
637
+ --tw-bg-opacity: 1;
638
+ background-color: rgb(240 253 244 / var(--tw-bg-opacity));
639
+ }
640
+ .bg-red-50 {
641
+ --tw-bg-opacity: 1;
642
+ background-color: rgb(254 242 242 / var(--tw-bg-opacity));
643
+ }
630
644
  .bg-green-100 {
631
645
  --tw-bg-opacity: 1;
632
646
  background-color: rgb(220 252 231 / var(--tw-bg-opacity));
@@ -658,6 +672,10 @@
658
672
  padding-left: 0.625rem;
659
673
  padding-right: 0.625rem;
660
674
  }
675
+ .px-3 {
676
+ padding-left: 0.75rem;
677
+ padding-right: 0.75rem;
678
+ }
661
679
  .py-1 {
662
680
  padding-top: 0.25rem;
663
681
  padding-bottom: 0.25rem;
@@ -702,12 +720,23 @@
702
720
  font-size: 0.875rem;
703
721
  line-height: 1.25rem;
704
722
  }
723
+ .font-medium {
724
+ font-weight: 500;
725
+ }
705
726
  .font-bold {
706
727
  font-weight: 700;
707
728
  }
708
729
  .font-semibold {
709
730
  font-weight: 600;
710
731
  }
732
+ .text-green-500 {
733
+ --tw-text-opacity: 1;
734
+ color: rgb(34 197 94 / var(--tw-text-opacity));
735
+ }
736
+ .text-red-500 {
737
+ --tw-text-opacity: 1;
738
+ color: rgb(239 68 68 / var(--tw-text-opacity));
739
+ }
711
740
  .text-blue-500 {
712
741
  --tw-text-opacity: 1;
713
742
  color: rgb(59 130 246 / var(--tw-text-opacity));
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html class="h-full">
3
3
  <head>
4
- <title>Litestream Rails</title>
4
+ <title>Litestream</title>
5
5
  <%= csrf_meta_tags %>
6
6
  <%= csp_meta_tag %>
7
7
 
@@ -24,7 +24,7 @@
24
24
  <p id="notice"
25
25
  class="py-2 px-3 bg-green-50 text-green-500 font-medium rounded-lg inline-block"
26
26
  data-controller="fade">
27
- <%= notice %>
27
+ <%= notice.html_safe %>
28
28
  </p>
29
29
  <% end %>
30
30
 
@@ -32,7 +32,7 @@
32
32
  <p id="alert"
33
33
  class="py-2 px-3 bg-red-50 text-red-500 font-medium rounded-lg inline-block"
34
34
  data-controller="fade">
35
- <%= alert %>
35
+ <%= alert.html_safe %>
36
36
  </p>
37
37
  <% end %>
38
38
  </div>
@@ -45,7 +45,7 @@
45
45
  element.classList.add('opacity-0')
46
46
  element.remove()
47
47
  },
48
- 2000
48
+ 5000
49
49
  )
50
50
  }
51
51
  document.querySelectorAll('[data-controller="fade"]').forEach(element => {
@@ -52,7 +52,7 @@
52
52
  <h2 class="text-lg font-bold">
53
53
  <code><%= database['path'] %></code>
54
54
  </h2>
55
- <button type="button" class="rounded-md bg-slate-800 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-slate-700">Restore</button>
55
+ <%= button_to "Restore", restorations_path, class: "rounded-md bg-slate-800 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-slate-700", params: { database: database['path'] } %>
56
56
  </div>
57
57
 
58
58
  <br />
data/config/routes.rb CHANGED
@@ -2,4 +2,5 @@ LitestreamRails::Engine.routes.draw do
2
2
  get "/" => "processes#show", :as => :root
3
3
 
4
4
  resource :process, only: [:show], path: ""
5
+ resources :restorations, only: [:create]
5
6
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LitestreamRails
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: litestream_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Margheim
@@ -91,6 +91,7 @@ files:
91
91
  - Rakefile
92
92
  - app/controllers/litestream_rails/application_controller.rb
93
93
  - app/controllers/litestream_rails/processes_controller.rb
94
+ - app/controllers/litestream_rails/restorations_controller.rb
94
95
  - app/views/layouts/litestream_rails/_style.html
95
96
  - app/views/layouts/litestream_rails/application.html.erb
96
97
  - app/views/litestream_rails/processes/show.html.erb