beautiful_url 1.5.90

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +112 -0
  3. data/beautiful_url.gemspec +60 -0
  4. data/bin/beautiful_url +9 -0
  5. data/doc/README.gen +65 -0
  6. data/lib/beautiful_url/class/constants.rb +23 -0
  7. data/lib/beautiful_url/class/generate_tab_completion_for_bash_shell.rb +67 -0
  8. data/lib/beautiful_url/class/initialize.rb +149 -0
  9. data/lib/beautiful_url/class/misc.rb +486 -0
  10. data/lib/beautiful_url/class/reset.rb +50 -0
  11. data/lib/beautiful_url/class/run.rb +20 -0
  12. data/lib/beautiful_url/constants/base_constants.rb +249 -0
  13. data/lib/beautiful_url/constants/constants.rb +9 -0
  14. data/lib/beautiful_url/constants/encoding.rb +48 -0
  15. data/lib/beautiful_url/constants/misc.rb +14 -0
  16. data/lib/beautiful_url/constants/newline.rb +14 -0
  17. data/lib/beautiful_url/constants/tasks.rb +30 -0
  18. data/lib/beautiful_url/constants/time.rb +21 -0
  19. data/lib/beautiful_url/json_generator/json_generator.rb +85 -0
  20. data/lib/beautiful_url/project/project.rb +23 -0
  21. data/lib/beautiful_url/requires/failsafe_require_of_beautiful_url.rb +9 -0
  22. data/lib/beautiful_url/requires/require_the_beautiful_url_project.rb +15 -0
  23. data/lib/beautiful_url/toplevel_methods/current_month.rb +32 -0
  24. data/lib/beautiful_url/toplevel_methods/jobs_menu.rb +118 -0
  25. data/lib/beautiful_url/toplevel_methods/local_menu.rb +2764 -0
  26. data/lib/beautiful_url/toplevel_methods/menu.rb +123 -0
  27. data/lib/beautiful_url/toplevel_methods/misc.rb +73 -0
  28. data/lib/beautiful_url/toplevel_methods/moodle_menu.rb +135 -0
  29. data/lib/beautiful_url/toplevel_methods/new_university_menu.rb +2852 -0
  30. data/lib/beautiful_url/toplevel_methods/pdf_books_menu.rb +32 -0
  31. data/lib/beautiful_url/toplevel_methods/return_location_of_the_menu_file.rb +27 -0
  32. data/lib/beautiful_url/toplevel_methods/roebe.rb +17 -0
  33. data/lib/beautiful_url/toplevel_methods/science_menu.rb +561 -0
  34. data/lib/beautiful_url/toplevel_methods/traditional_menu.rb +6404 -0
  35. data/lib/beautiful_url/toplevel_methods/university_menu.rb +12655 -0
  36. data/lib/beautiful_url/toplevel_methods/video_menu.rb +1570 -0
  37. data/lib/beautiful_url/version/version.rb +26 -0
  38. data/lib/beautiful_url/www/app.rb +168 -0
  39. data/lib/beautiful_url.rb +1 -0
  40. data/test/testing_beautiful_url.rb +56 -0
  41. data/test/testing_the_base_constants.rb +26 -0
  42. metadata +107 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 91e778f20ea7bb24bd59aa2dbeeeeb069f26170dd5b607b1464a2e560a6785d5
4
+ data.tar.gz: 88ef93f10af9e6be7be161c1d2e75bf547841aa6fc7e9a871259a887696d7e5a
5
+ SHA512:
6
+ metadata.gz: c128c36d2ba899a919d62618bfa3ecddaaae9883079fa4f146b99f51dbf3935ceae6963faa583822a29bbe9fb52d2ad71a886e83e935ccecc1155b00092c0485
7
+ data.tar.gz: 8e2026d22860a443cee4e6ab77c0ad41d92b0b93f15d189b4b62211364c3f0b09245785323c71ed29ef8dd0ba781ab9bb512e69cb8dd4404d4b2db8b39e63c05
data/README.md ADDED
@@ -0,0 +1,112 @@
1
+ [![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://www.gobolinux.org/)
2
+ [![forthebadge](https://forthebadge.com/images/badges/made-with-ruby.svg)](https://www.ruby-lang.org/en/)
3
+ [![Gem Version](https://badge.fury.io/rb/beautiful_url.svg)](https://badge.fury.io/rb/beautiful_url)
4
+
5
+ This gem was <b>last updated</b> on the <span style="color: darkblue; font-weight: bold">15.04.2024</span> (dd.mm.yyyy notation), at <span style="color: steelblue; font-weight: bold">10:55:12</span> o'clock.
6
+
7
+ ## Introducing the BeautifulUrl project
8
+
9
+ <img src="https://i.imgur.com/w9Ws8CP.png" style="margin:1em; border: 3px solid black;">
10
+
11
+ This project has been created to primarily cover my needs to map a
12
+ given input (typically a symbol, such as :ruby_homepage), to
13
+ a specific String - a remote URL, in this case
14
+ **https://www.ruby-lang.org/en/**.
15
+
16
+ In fact this is the primary scenario for this project: it provides
17
+ a simple mapper between symbols, and remote URLs.
18
+
19
+ At a later time I also added symbols as shortcuts to local files,
20
+ so the whole project is a quick way for me to navigate different
21
+ resources (including **RESTful APIs**).
22
+
23
+ I may at a later point add the ability to arbitrarily add new
24
+ entries via a yaml file, so that other people can extend this
25
+ project at their own leisure - but for now, the original use
26
+ case will be kept as-is. Extending the project may happen at
27
+ a later time.
28
+
29
+ ## General usage examples
30
+
31
+ BeautifulUrl::BeautifulUrl.new('palemoon', :replace_localhost)
32
+ BeautifulUrl::BeautifulUrl.new('palemoon' {{ replace_localhost: true }}
33
+ BeautifulUrl['palemoon'] # ← This is recommended, as it is simpler.
34
+
35
+ ## Creating a .json file
36
+
37
+ It is possible to create a local .json file containing all the
38
+ remote URLs that are registered. The method to do so is
39
+ called <b>BeautifulUrl.create_json_file()</b>. Note that
40
+ this functionality depends on the <b>case_parser</b> gem;
41
+ that gem does not work 100% accurately, so do not be surprised
42
+ if you do not get a complete .json file but only one with
43
+ the first entry matched. In the future this may be changed,
44
+ but for now this is the way it is.
45
+
46
+ ## Sinatra-Interface
47
+
48
+ The BeautifulUrl project has a minimalistic **sinatra interface**.
49
+
50
+ You can start it in this way:
51
+
52
+ require 'beautiful_url/www/app.rb'
53
+
54
+ BeautifulUrl::App.start_sinatra_interface
55
+
56
+ Note that this depends on an external gem (the **cyberweb** project).
57
+ The reason why that dependency exists is because it makes it easier
58
+ for me to handle the same or similar code across many different
59
+ ruby-based projects.
60
+
61
+ The main purpose of this Application is to map given string input into
62
+ the corresponding URL. It's mostly added for demonstration-purposes,
63
+ to show how this could be used in a web-interface.
64
+
65
+ One day I may also want to add a small widget to a browser to
66
+ allow for this, but I don't like javascript, and don't know
67
+ how to do this via ruby only either.
68
+
69
+
70
+ ## Contact information and mandatory 2FA (no longer) coming up in 2022 / 2023
71
+
72
+ If your creative mind has ideas and specific suggestions to make this gem
73
+ more useful in general, feel free to drop me an email at any time, via:
74
+
75
+ shevy@inbox.lt
76
+
77
+ Before that email I used an email account at Google gmail, but in **2021** I
78
+ decided to slowly abandon gmail, for various reasons. In order to limit the
79
+ explanation here, allow me to just briefly state that I do not feel as if I
80
+ want to promote any Google service anymore when the user becomes the end
81
+ product (such as via data collection by upstream services, including other
82
+ proxy-services). My feeling is that this is a hugely flawed business model
83
+ to begin with, and I no longer wish to support this in any way, even if
84
+ only indirectly so, such as by using services of companies that try to
85
+ promote this flawed model.
86
+
87
+ In regards to responding to emails: please keep in mind that responding
88
+ may take some time, depending on the amount of work I may have at that
89
+ moment. So it is not that emails are ignored; it is more that I have not
90
+ (yet) found the time to read and reply. This means there may be a delay
91
+ of days, weeks and in some instances also months. There is, unfortunately,
92
+ not much I can do when I need to prioritise my time investment, but I try
93
+ to consider <b>all</b> feedback as an opportunity to improve my projects
94
+ nonetheless.
95
+
96
+ In <b>2022</b> rubygems.org decided to make 2FA mandatory for every
97
+ gem owner eventually:
98
+
99
+ see
100
+ https://blog.rubygems.org/2022/06/13/making-packages-more-secure.html
101
+
102
+ However had, that has been reverted again, so I decided to shorten
103
+ this paragraph. Mandatory 2FA may exclude users who do not have a
104
+ smartphone device or other means to 'identify'. I do not feel it is
105
+ a fair assumption by others to be made that non-identified people may
106
+ not contribute code, which is why I reject it. Mandatory 2FA would mean
107
+ an end to all my projects on rubygems.org, so let's hope it will never
108
+ happen. (Keep in mind that I refer to mandatory 2FA; I have no qualms
109
+ for people who use 2FA on their own, but this carrot-and-stick strategy
110
+ by those who control the rubygems infrastructure is a very bad one to
111
+ pursue.
112
+
@@ -0,0 +1,60 @@
1
+ # =========================================================================== #
2
+ # Gemspec for Beautiful URL.
3
+ # =========================================================================== #
4
+ require 'beautiful_url'
5
+ require 'roebe/toplevel_methods/misc.rb'
6
+
7
+ Gem::Specification.new { |s|
8
+
9
+ s.name = 'beautiful_url'
10
+ s.version = BeautifulUrl.version?
11
+ s.date = Time.now.strftime('%Y-%m-%d')
12
+
13
+ DESCRIPTION = <<-EOF
14
+
15
+ This is a medium-sized gem which attempts to handle "matching" a String
16
+ or a Symbol against (remote) URLs. The project was created in order to
17
+ use short identifiers that can pinpoint to remote URLs, a bit similar
18
+ to how shorturl is working.
19
+
20
+ The gem is, however had, tailored to my use cases, so it will most
21
+ likely be utterly useless to other people by default. Most downloads
22
+ of this gem happen by scripts and bots, so do not think that the
23
+ download numbers imply anything about "real" usage - the gem is
24
+ way too much tailored to my own use case.
25
+
26
+ In the long run, though, the project may be extended to allow the
27
+ custom loading of yaml files, for a later release - but for now,
28
+ I do not think that this project will be useful to anyone else.
29
+
30
+ More documentation can be found at:
31
+
32
+ https://www.rubydoc.info/gems/beautiful_url/
33
+
34
+ EOF
35
+
36
+ # ========================================================================= #
37
+ # Show this when a user installs this gem.
38
+ # ========================================================================= #
39
+ s.post_install_message = <<-EOF
40
+
41
+ You should be able to invoke bin/beautiful_url via:
42
+
43
+ beautiful_url
44
+
45
+ EOF
46
+
47
+ s.summary = DESCRIPTION
48
+ s.description = DESCRIPTION
49
+
50
+ s.authors = ["Robert A. Heiler"]
51
+ s.email = Roebe.email?
52
+ s.files = Dir["**/*"]
53
+ s.licenses = 'MIT'
54
+ s.homepage = 'https://rubygems.org/gems/beautiful_url'
55
+
56
+ s.required_ruby_version = '>= '+RUBY_VERSION
57
+ s.required_rubygems_version = '>= '+Gem::VERSION
58
+ s.rubygems_version = '>= '+Gem::VERSION
59
+
60
+ }
data/bin/beautiful_url ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'beautiful_url'
6
+
7
+ result = BeautifulUrl.fetch_value(ARGV.first)
8
+
9
+ puts result
data/doc/README.gen ADDED
@@ -0,0 +1,65 @@
1
+ DEFAULT_HEADER
2
+
3
+ ## Introducing the BeautifulUrl project
4
+
5
+ <img src="https://i.imgur.com/w9Ws8CP.png" style="margin:1em; border: 3px solid black;">
6
+
7
+ This project has been created to primarily cover my needs to map a
8
+ given input (typically a symbol, such as :ruby_homepage), to
9
+ a specific String - a remote URL, in this case
10
+ **https://www.ruby-lang.org/en/**.
11
+
12
+ In fact this is the primary scenario for this project: it provides
13
+ a simple mapper between symbols, and remote URLs.
14
+
15
+ At a later time I also added symbols as shortcuts to local files,
16
+ so the whole project is a quick way for me to navigate different
17
+ resources (including **RESTful APIs**).
18
+
19
+ I may at a later point add the ability to arbitrarily add new
20
+ entries via a yaml file, so that other people can extend this
21
+ project at their own leisure - but for now, the original use
22
+ case will be kept as-is. Extending the project may happen at
23
+ a later time.
24
+
25
+ ## General usage examples
26
+
27
+ BeautifulUrl::BeautifulUrl.new('palemoon', :replace_localhost)
28
+ BeautifulUrl::BeautifulUrl.new('palemoon' {{ replace_localhost: true }}
29
+ BeautifulUrl['palemoon'] # ← This is recommended, as it is simpler.
30
+
31
+ ## Creating a .json file
32
+
33
+ It is possible to create a local .json file containing all the
34
+ remote URLs that are registered. The method to do so is
35
+ called <b>BeautifulUrl.create_json_file()</b>. Note that
36
+ this functionality depends on the <b>case_parser</b> gem;
37
+ that gem does not work 100% accurately, so do not be surprised
38
+ if you do not get a complete .json file but only one with
39
+ the first entry matched. In the future this may be changed,
40
+ but for now this is the way it is.
41
+
42
+ ## Sinatra-Interface
43
+
44
+ The BeautifulUrl project has a minimalistic **sinatra interface**.
45
+
46
+ You can start it in this way:
47
+
48
+ require 'beautiful_url/www/app.rb'
49
+
50
+ BeautifulUrl::App.start_sinatra_interface
51
+
52
+ Note that this depends on an external gem (the **cyberweb** project).
53
+ The reason why that dependency exists is because it makes it easier
54
+ for me to handle the same or similar code across many different
55
+ ruby-based projects.
56
+
57
+ The main purpose of this Application is to map given string input into
58
+ the corresponding URL. It's mostly added for demonstration-purposes,
59
+ to show how this could be used in a web-interface.
60
+
61
+ One day I may also want to add a small widget to a browser to
62
+ allow for this, but I don't like javascript, and don't know
63
+ how to do this via ruby only either.
64
+
65
+ ADD_CONTACT_INFORMATION
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'beautiful_url/class/constants.rb'
6
+ # =========================================================================== #
7
+ require 'beautiful_url/constants/constants.rb'
8
+
9
+ module BeautifulUrl
10
+
11
+ class BeautifulUrl # === BeautifulUrl::BeautifulUrl
12
+
13
+ # ========================================================================= #
14
+ # === RUN_ALREADY
15
+ # ========================================================================= #
16
+ RUN_ALREADY = true
17
+
18
+ # ========================================================================= #
19
+ # === DEFAULT_URL
20
+ # ========================================================================= #
21
+ DEFAULT_URL = 'http://localhost/DATA/PROGRAMMING_LANGUAGES/R/R.cgi'
22
+
23
+ end; end
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'beautiful_url/class/generate_tab_completion_for_bash_shell.rb'
6
+ # =========================================================================== #
7
+ module BeautifulUrl
8
+
9
+ class BeautifulUrl # It is part of the class.
10
+
11
+ begin
12
+ require 'save_file'
13
+ rescue LoadError; end
14
+
15
+ # ========================================================================= #
16
+ # === generate_tab_completion_for_bash_shell
17
+ #
18
+ # This entry point will generate the tab-completion for the BASH shell.
19
+ #
20
+ # Invocation examples:
21
+ #
22
+ # purl GENERATE
23
+ # purl --generate
24
+ #
25
+ # ========================================================================= #
26
+ def generate_tab_completion_for_bash_shell
27
+ begin
28
+ require 'collect_first_word_of_case_menu'
29
+ rescue LoadError; end
30
+ begin
31
+ require 'opn'
32
+ rescue LoadError; end
33
+ opn; e 'Now generating tab completion for the bash shell.'
34
+ _ = ''.dup # This is the string to store.
35
+ _ << 'completion_for_purl()
36
+ {
37
+ local cur complete_these_words
38
+
39
+ COMPREPLY=() # Array variable storing the possible completions.
40
+ cur="${COMP_WORDS[COMP_CWORD]}"
41
+ complete_these_words="'
42
+ beautiful_menu = ::BeautifulUrl[:beautiful_menu]
43
+ if beautiful_menu.is_a? Array
44
+ beautiful_menu = beautiful_menu.first
45
+ end
46
+ results = CollectFirstWordOfCaseMenu.new(beautiful_menu).result
47
+ results.sort.each {|entry|
48
+ _ << entry+"\n"
49
+ }
50
+ _ << ' "
51
+
52
+ if [[ ${cur} == * ]] ; then
53
+ COMPREPLY=( $(compgen -W "${complete_these_words}" -- ${cur}) )
54
+ return 0
55
+ fi
56
+ }
57
+ # Next, available auto-completion for the commands "purl" and "url".
58
+ complete -F completion_for_purl url
59
+ complete -F completion_for_purl purl
60
+ '
61
+ store_where =
62
+ "#{BASE_DIR}DATA/PC/OS/LINUX/SHELL/SCRIPTS/completion_for_purl.sh"
63
+ opn; e 'We will store at `'+store_where+'`.'
64
+ SaveFile.write_what_into(_, store_where)
65
+ end; alias generate_tab_completion generate_tab_completion_for_bash_shell # === generate_tab_completion
66
+
67
+ end; end # bmenu
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === BeautifulUrl::BeautifulUrl
6
+ #
7
+ # The class BeautifulUrl wants to make it easier to open local pages -
8
+ # but it can also make use of shortcuts for remote files.
9
+ #
10
+ # It additionally supports the usage of intralinks, e.g. if you wish
11
+ # to append something like '#foo' to a html page, it is possible
12
+ # through this project.
13
+ #
14
+ # See below for some specific usage examples.
15
+ #
16
+ # In the event that a substitute for the given input can not be found,
17
+ # we will return the original input unmodified.
18
+ #
19
+ # Specific usage examples for class BeautifulUrl in ruby code:
20
+ #
21
+ # require 'beautiful_url'
22
+ # url = BeautifulUrl.new('science_news')
23
+ # url.input?; url.url?; url.remote?
24
+ # url.do_replace_localhost
25
+ # url.replace_data
26
+ # x = BeautifulUrl.new 'geastask'
27
+ # BeautifulUrl.new('slogans').url?
28
+ # BeautifulUrl.new('geastask').url_was_found
29
+ # BeautifulUrl.new('cmd#chroot') # => "http://localhost/DATA/PC/OS/LINUX/LINUX_COMMANDS.cgi#chroot"
30
+ #
31
+ # =========================================================================== #
32
+ # require 'beautiful_url/class/initialize.rb'
33
+ # =========================================================================== #
34
+ require 'beautiful_url/class/constants.rb'
35
+ require 'beautiful_url/class/misc.rb'
36
+ require 'beautiful_url/class/reset.rb'
37
+ require 'beautiful_url/class/run.rb'
38
+
39
+ module BeautifulUrl
40
+
41
+ class BeautifulUrl # === BeautifulUrl::BeautifulUrl
42
+
43
+ alias e puts
44
+
45
+ # ========================================================================= #
46
+ # === initialize
47
+ #
48
+ # Usage examples:
49
+ #
50
+ # x = BeautifulUrl::BeautifulUrl.new('palemoon', :replace_localhost)
51
+ # x = BeautifulUrl::BeautifulUrl.new('palemoon' {{ replace_localhost: true }}
52
+ #
53
+ # ========================================================================= #
54
+ def initialize(
55
+ commandline_arguments = ARGV,
56
+ run_already = RUN_ALREADY,
57
+ &block
58
+ )
59
+ reset # Must come first.
60
+ case commandline_arguments # case tag
61
+ # ======================================================================= #
62
+ # === :dont_run_yet
63
+ # ======================================================================= #
64
+ when :dont_run_yet,
65
+ :do_not_run_yet
66
+ commandline_arguments = DEFAULT_URL
67
+ run_already = false
68
+ end
69
+ set_commandline_arguments(
70
+ commandline_arguments
71
+ )
72
+ case run_already
73
+ # ======================================================================= #
74
+ # === :replace_localhost
75
+ # ======================================================================= #
76
+ when :replace_localhost,
77
+ :replace,
78
+ :replace_localhost_with_data,
79
+ :do_replace_localhost
80
+ @replace_localhost_with_data = true # Default, as this is more important.
81
+ run_already = RUN_ALREADY
82
+ else
83
+ if run_already.is_a? Hash # Must come after reset().
84
+ # =================================================================== #
85
+ # === :replace_localhost
86
+ # =================================================================== #
87
+ if run_already.has_key? :replace_localhost
88
+ @replace_localhost_with_data = run_already[:replace_localhost]
89
+ run_already = RUN_ALREADY # Restore the default again.
90
+ # =================================================================== #
91
+ # === :replace
92
+ # =================================================================== #
93
+ elsif run_already.has_key? :replace
94
+ @replace_localhost_with_data = run_already[:replace]
95
+ run_already = RUN_ALREADY # Restore the default again.
96
+ end
97
+ end
98
+ end
99
+ # ======================================================================= #
100
+ # === Handle blocks given to us
101
+ #
102
+ # This has to occur before run() is called.
103
+ # ======================================================================= #
104
+ if block_given?
105
+ yielded = yield
106
+ case yielded
107
+ # ===================================================================== #
108
+ # === :do_not_replace_the_localhost
109
+ # ===================================================================== #
110
+ when :do_not_replace_the_localhost
111
+ # In this case do nothing.
112
+ # ===================================================================== #
113
+ # ===:replace_localhost
114
+ # ===================================================================== #
115
+ when :replace_localhost
116
+ @replace_localhost_with_data = true
117
+ end
118
+ end
119
+ run if run_already
120
+ end
121
+
122
+ end; end
123
+
124
+ if __FILE__ == $PROGRAM_NAME
125
+ _ = BeautifulUrl::BeautifulUrl.new(ARGV)
126
+ pp _
127
+ puts _.return_corresponding_entry
128
+ _.get_rid_of_localhost
129
+ puts _.return_corresponding_entry
130
+ end # rb initialize.rb rubyreddit
131
+ # rb initialize.rb palemoon
132
+ # Testing this class next:
133
+ # purl diepasst
134
+ # purl pc
135
+ # purl anmeldung
136
+ # purl pc replace
137
+ # purl GENERATE
138
+ # purl science_news
139
+ # burl ruby#windows
140
+ # burl std#amino_acids
141
+ # burl cmd cat
142
+ # burl scinews
143
+ # burl gobodist_homepage
144
+ # sani geastask
145
+ # purl GENERATE
146
+ # burl gobodist
147
+ # burl gobodist#Compile
148
+ # burl local_php#test
149
+ # burl stdk#Periodensystem