noticesys 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8dd1393e55e8b90efda85d824f9a9ee9111a2802386c663e25f4b96e1f894cd6
4
+ data.tar.gz: add7a94854c0dd48d711772c8aa703731bf6d36484289be76a25f55cd6872827
5
+ SHA512:
6
+ metadata.gz: b521dc650d991b843ab5977b8150e8ad9809f5a11fc09d2afe8fa853cc5ee40e6def90a0ddcfb6718d12096738a2c16c44995093aff8491fe3ace6e6c852410f
7
+ data.tar.gz: 75357c37d9d1c8de344e3227a466e0345d96350b53a844dc2daf82b32f773715dbdcff1f2025f8397a0c51761aa6802823435c79ed4bdd184af17b45ab0c344f
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
Binary file
data/lib/noticesys.rb ADDED
@@ -0,0 +1,122 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: noticesys.rb
4
+
5
+ require 'down' # file downloader
6
+ require 'ogextractor' # extract metadata
7
+
8
+
9
+ module NoticeSys
10
+
11
+ class Client
12
+
13
+ def initialize(user='', rmagick=nil)
14
+ @user, @rmagick = user, rmagick
15
+ end
16
+
17
+ # params expected: msg, file1, file2, file3
18
+ #
19
+ def send_input(params={})
20
+
21
+ # save the file attachments containing the images etc.
22
+
23
+ files = (1..3).map do |n|
24
+
25
+ f = params['file' + n.to_s]
26
+ next unless f
27
+
28
+ original = f[:tempfile].to_path
29
+
30
+ scale_img original
31
+
32
+ end.compact
33
+
34
+ msg = params['msg']
35
+
36
+ urls = msg.scan(/https:\/\/[^ ]+/)
37
+
38
+ if urls.any? then
39
+
40
+ h2 = OgExtractor.new(urls.last).to_h
41
+
42
+ if h2 then
43
+ h = {msg: msg, files: files}
44
+
45
+ h[:site]= h2[:url][/https?:\/\/([^\/]+)/,1].sub(/^www\./,'')
46
+
47
+ tmpfile = Down.download h2[:img]
48
+ files2 = scale_img tmpfile.to_path
49
+
50
+ h[:files] = files2
51
+ h[:card] = {h2[:card] => { title: h2[:title], desc: h2[:desc], url: h2[:url]}}
52
+ h[:msg] = msg.sub(urls.last,'')
53
+
54
+ return "notice/%s/json: %s" % [@user, h.to_json]
55
+
56
+ end
57
+
58
+ end
59
+
60
+ return "notice/%s: %s" % [@user, msg]
61
+
62
+ end
63
+
64
+ private
65
+
66
+ def scale_img(raworiginal)
67
+
68
+ original = if raworiginal =~ /\.\w+$/ then
69
+
70
+ raworiginal
71
+
72
+ else
73
+
74
+ neworiginal = raworiginal + '.jpg'
75
+ FileUtils.mv raworiginal, neworiginal
76
+ neworiginal
77
+
78
+ end
79
+
80
+ res = %w(240x240 360x360 *518x389 1280x720 2048x1080)
81
+ a = @rmagick.resize(original, res)
82
+ a2 = (a + [nil,nil,nil]).take(res.length)
83
+
84
+ oldfile = nil
85
+ sizes = %w(240x240 360x360 small medium large)
86
+
87
+ file_sizes = a2.zip(sizes).map.with_index do |x, i|
88
+
89
+ f, label = x
90
+
91
+ if f then
92
+
93
+ f2 = f.sub(/_(n\d+x\d+)\.\w+$/) {|x| x.sub($1, label)}
94
+
95
+ FileUtils.mv f, f2
96
+ oldfile = f2
97
+
98
+ elsif oldfile
99
+
100
+ f2 = oldfile.sub(/_(\w+)\.\w+$/) {|x| x.sub($1, label)}
101
+
102
+ oldfile = original if i == a.length - 1
103
+
104
+ FileUtils.cp oldfile, f2
105
+
106
+ end
107
+
108
+
109
+ f2
110
+
111
+ end
112
+
113
+ imgfile = original.sub(/\.\w+$/,'2\0')
114
+ FileUtils.mv original, imgfile
115
+
116
+ file_sizes << imgfile
117
+
118
+ end
119
+
120
+ end
121
+
122
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: noticesys
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERT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6EAbiHcZWJbQaRqEEdDP0kv7rygFxSeTh2b
29
+ ORS34n4BLflqFIKO/2QFRMP9PDEg2WOsTgqNt2zvi6nhUX3io1ZQXjF0bcEh4lXI
30
+ rJei7zIid8fg/TQkKcsQ7zZRVBVff/D9VRtGIofCvQoYXrXF2IWSxnezdq/xzW6V
31
+ CdFI37XlEuNAO1ijhKnfwLrGPbZpN/4j9IhxQArwSKdehjmOQaNDW3IdteYGZfD4
32
+ xKpzqGIlQ8d2X8sYIkk4zPdW5yqwgbSltgAOeSNGhlkcEUAxjHtFXJq3LW8A1arv
33
+ BtD2GsHdYt5DuB8yHZZmIOFj5kytIhWuuMEu1mNEWrKV8SWUbKt2jP86fFxNcLvK
34
+ ouLtRlxE/c6pHpW62g23N/T9dWSKCjYAkoqB/stIoIs7wgOLlmhPjKtW4miEuIHg
35
+ iGAgDWBQqM/kdjDslqjBGtyWyFyuYHzXMU1gO/P0aE3rh1enqahZ8BqY+gxXLGrR
36
+ sU+WFV9qPqoqNOG0tOknOZXN
37
+ -----END CERTIFICATE-----
38
+ date: 2021-04-02 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: down
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 5.2.0
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '5.2'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 5.2.0
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '5.2'
60
+ - !ruby/object:Gem::Dependency
61
+ name: ogextractor
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '0.1'
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 0.1.1
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '0.1'
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 0.1.1
80
+ description:
81
+ email: digital.robertson@gmail.com
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - lib/noticesys.rb
87
+ homepage: https://github.com/jrobertson/noticesys
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.7.10
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: A small part of an experimental microblogging system.
111
+ test_files: []
metadata.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ ��l�ec��3.�|:G�~�����5�/M4j���o��A�������X}7$tf�t��ᣗ�)�Ez�r�7���gŐH�A> �����;��7�V��&|iEA���g;}�Pڝ���7�zj�ђ�q��_gU+g����f<oR��� }�p�M���`̬��U���rr+�
2
+ ;�}�w��Z[&%Yr