lgm 0.0.7 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/lgm +10 -0
- data/server/Gemfile +1 -0
- data/server/Gemfile.lock +2 -0
- data/server/app.rb +7 -3
- data/server/constants.rb +1 -0
- data/server/link.rb +4 -0
- data/server/links.rb +28 -0
- data/static/dist/index.html +1 -1
- data/static/dist/main.js +12 -2
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71fd71b6ec54a4033374cdbbee1d16e8802abcfa
|
4
|
+
data.tar.gz: 7f7429d9591ecfb695777d61b1635788d3d4df2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d48c2db945fc5010dff99bddae7d2cd0bf1b9533a1376e65abb177d3f81f9cc5e1e563556158118f6f7a3e54cedd55f154146ebeb7c64ef3081901526105629b
|
7
|
+
data.tar.gz: f582373a833a73af885d1a1d0422834b78a9b32b71e23b3c3e9d2a2ebe4e5f5511af1c06eb954b4bbdd0a4a1c74ea390f1f76dfaf65e033bc2c4370411c817c2
|
data/bin/lgm
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require_relative '../server/constants'
|
4
|
+
require 'fileutils'
|
5
|
+
FileUtils.mkdir_p LGM_DIR
|
6
|
+
|
7
|
+
Thread.new do
|
8
|
+
`redis-server --unixsocket #{LGM_DIR}/redis.sock --port 0 --dir #{LGM_DIR} --appendonly yes`
|
9
|
+
end
|
10
|
+
at_exit { R.shutdown }
|
11
|
+
|
12
|
+
|
3
13
|
require 'puma'
|
4
14
|
require_relative '../server/app'
|
5
15
|
|
data/server/Gemfile
CHANGED
data/server/Gemfile.lock
CHANGED
data/server/app.rb
CHANGED
@@ -2,7 +2,7 @@ require 'hobby'
|
|
2
2
|
require 'hobby/json'
|
3
3
|
|
4
4
|
require_relative 'link'
|
5
|
-
|
5
|
+
require_relative 'links'
|
6
6
|
|
7
7
|
class API
|
8
8
|
include Hobby
|
@@ -15,13 +15,17 @@ class API
|
|
15
15
|
post '/links' do
|
16
16
|
link = Link.new json['link']
|
17
17
|
|
18
|
-
if link.valid?
|
19
|
-
LINKS
|
18
|
+
if link.valid? && ( not LINKS.include? link )
|
19
|
+
LINKS.add link
|
20
20
|
link
|
21
21
|
else
|
22
22
|
response.status = 422
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
get '/links/amount' do
|
27
|
+
LINKS.amount
|
28
|
+
end
|
25
29
|
end
|
26
30
|
|
27
31
|
class App
|
data/server/constants.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
LGM_DIR = "#{ENV['HOME']}/.lgm"
|
data/server/link.rb
CHANGED
data/server/links.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'redis'
|
2
|
+
require_relative 'constants'
|
3
|
+
R = Redis.new path: "#{LGM_DIR}/redis.sock"
|
4
|
+
|
5
|
+
module LINKS
|
6
|
+
extend self
|
7
|
+
|
8
|
+
def add link
|
9
|
+
R.lpush 'links_list', link
|
10
|
+
R.sadd 'links_set', link
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_json
|
14
|
+
to_a.to_json
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_a
|
18
|
+
R.lrange 'links_list', 0, -1
|
19
|
+
end
|
20
|
+
|
21
|
+
def include? link
|
22
|
+
R.sismember 'links_set', link
|
23
|
+
end
|
24
|
+
|
25
|
+
def amount
|
26
|
+
R.scard 'links_set'
|
27
|
+
end
|
28
|
+
end
|
data/static/dist/index.html
CHANGED
@@ -1 +1 @@
|
|
1
|
-
<!DOCTYPE html><head><title>CRM | Lead Gathering Machine</title><meta charset="utf-8"></head><body><div id="main"></div><script type="text/javascript" src="main.js?
|
1
|
+
<!DOCTYPE html><head><title>CRM | Lead Gathering Machine</title><meta charset="utf-8"></head><body><div id="main"></div><script type="text/javascript" src="main.js?edd53b2871bc06b206bd"></script></body>
|
data/static/dist/main.js
CHANGED
@@ -702,7 +702,8 @@ module.exports = {
|
|
702
702
|
data: function() {
|
703
703
|
return {
|
704
704
|
link: "",
|
705
|
-
links: []
|
705
|
+
links: [],
|
706
|
+
total_amount_of_links: 0
|
706
707
|
};
|
707
708
|
},
|
708
709
|
methods: {
|
@@ -713,14 +714,21 @@ module.exports = {
|
|
713
714
|
}));
|
714
715
|
if (response.status === 200) {
|
715
716
|
this.links.unshift(response.data);
|
717
|
+
this.get_total_amount_of_links();
|
716
718
|
return this.link = "";
|
717
719
|
} else {
|
718
720
|
return console.log(`Invalid link: ${this.link}`);
|
719
721
|
}
|
722
|
+
},
|
723
|
+
get_total_amount_of_links: async function() {
|
724
|
+
var response;
|
725
|
+
response = (await axios.get('/api/links/amount'));
|
726
|
+
return this.total_amount_of_links = response.data;
|
720
727
|
}
|
721
728
|
},
|
722
729
|
created: async function() {
|
723
730
|
var response;
|
731
|
+
this.get_total_amount_of_links();
|
724
732
|
response = (await axios.get('/api/links'));
|
725
733
|
return this.links = response.data;
|
726
734
|
}
|
@@ -10892,7 +10900,9 @@ var render = function() {
|
|
10892
10900
|
}
|
10893
10901
|
}),
|
10894
10902
|
_c("p", [
|
10895
|
-
_vm._v(
|
10903
|
+
_vm._v(
|
10904
|
+
"Total amount of links: " + _vm._s(_vm.total_amount_of_links) + "."
|
10905
|
+
)
|
10896
10906
|
]),
|
10897
10907
|
_c(
|
10898
10908
|
"ol",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lgm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anatoly Chernow
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: redis
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: puma
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +64,9 @@ files:
|
|
50
64
|
- server/Gemfile.lock
|
51
65
|
- server/app.rb
|
52
66
|
- server/config.ru
|
67
|
+
- server/constants.rb
|
53
68
|
- server/link.rb
|
69
|
+
- server/links.rb
|
54
70
|
- static/dist/index.html
|
55
71
|
- static/dist/main.js
|
56
72
|
homepage:
|