cliz 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/cliz +59 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d10663c001cb6860631422a9d914343afab05b4f2c48b49bbad6d8cbf4dcc7bd
|
4
|
+
data.tar.gz: abfe76359ea3a444e80fad9515766fdd14038c312ded8e745d9d9c0607cf4ee1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 22b57d559cdd2ae437314833a531349b3db9226251360e78f6db5084420d8ac256e5410c46e7281a7520026a1a794f84a7c5505109c02f380151be049746f588
|
7
|
+
data.tar.gz: 2757403bcb2276202f91bc80e2df4b2ce3a6ff4601ba75518dfc306e9fbcf8975d7c2b746722f58f36750062c71abf0c9f7dafe1c6b1b63d7fcb974649cd05a7
|
data/bin/cliz
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'securerandom'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
config = YAML.load(File.read('config.yml'))
|
8
|
+
|
9
|
+
OUTPUT_DIR = config['output_dir']
|
10
|
+
BASE_DOMAIN = config['base_domain']
|
11
|
+
DEPLOY_SCRIPT = config['deploy_script']
|
12
|
+
HTML = %Q{
|
13
|
+
<!DOCTYPE html>
|
14
|
+
<html>
|
15
|
+
<head>
|
16
|
+
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
|
17
|
+
<meta content="utf-8" http-equiv="encoding">
|
18
|
+
<script type="text/javascript">
|
19
|
+
window.location.replace("https://cliz.in");
|
20
|
+
</script>
|
21
|
+
<meta http-equiv="refresh" content="0; url='https://cliz.in'" />
|
22
|
+
</head>
|
23
|
+
<body>
|
24
|
+
<p>Please follow <a href="https://cliz.in">this link</a>.</p>
|
25
|
+
</body>
|
26
|
+
</html>
|
27
|
+
}
|
28
|
+
|
29
|
+
url = ARGV[0]
|
30
|
+
redirect_content = HTML.gsub 'https://cliz.in', url
|
31
|
+
folder_path = nil
|
32
|
+
counter = 0
|
33
|
+
random_string = nil
|
34
|
+
|
35
|
+
unless ARGV[1]
|
36
|
+
loop do
|
37
|
+
random_string = SecureRandom.alphanumeric[..counter]
|
38
|
+
folder_path = "#{OUTPUT_DIR}/#{random_string}/"
|
39
|
+
break unless File.directory?(folder_path)
|
40
|
+
counter += 1
|
41
|
+
end
|
42
|
+
else
|
43
|
+
folder_path = "#{OUTPUT_DIR}/#{ARGV[1]}/"
|
44
|
+
random_string = ARGV[1]
|
45
|
+
if File.directory?(folder_path)
|
46
|
+
puts("This short is already taken. Try another.")
|
47
|
+
exit
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
FileUtils.mkdir_p(folder_path)
|
52
|
+
|
53
|
+
File.open "#{folder_path}/index.html", 'w' do |f|
|
54
|
+
f.puts redirect_content
|
55
|
+
end
|
56
|
+
|
57
|
+
system("sh #{DEPLOY_SCRIPT}") if DEPLOY_SCRIPT
|
58
|
+
|
59
|
+
puts "#{BASE_DOMAIN}#{random_string}"
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cliz
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Karthikeyan A K
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-11-29 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Cliz - The static URL shortner
|
14
|
+
email: mindaslab@protonmail.com
|
15
|
+
executables:
|
16
|
+
- cliz
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/cliz
|
21
|
+
homepage: https://cliz.in
|
22
|
+
licenses:
|
23
|
+
- GPLV3
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubygems_version: 3.1.4
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Cliz - The static URL shortner
|
44
|
+
test_files: []
|