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
@@ -0,0 +1,123 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # This file here shall primarily include the other menu-components.
6
+ # =========================================================================== #
7
+ # require 'beautiful_url/toplevel_methods/menu.rb'
8
+ # =========================================================================== #
9
+ module BeautifulUrl
10
+
11
+ require 'beautiful_url/constants/constants.rb'
12
+ require 'beautiful_url/toplevel_methods/local_menu.rb'
13
+ require 'beautiful_url/toplevel_methods/jobs_menu.rb'
14
+ require 'beautiful_url/toplevel_methods/misc.rb'
15
+ require 'beautiful_url/toplevel_methods/pdf_books_menu.rb'
16
+ require 'beautiful_url/toplevel_methods/roebe.rb'
17
+ require 'beautiful_url/toplevel_methods/science_menu.rb'
18
+ require 'beautiful_url/toplevel_methods/traditional_menu.rb'
19
+ require 'beautiful_url/toplevel_methods/new_university_menu.rb'
20
+ require 'beautiful_url/toplevel_methods/university_menu.rb'
21
+ require 'beautiful_url/toplevel_methods/video_menu.rb'
22
+
23
+ # ========================================================================= #
24
+ # === BeautifulUrl.menu
25
+ #
26
+ # This method will return a String or an Array.
27
+ #
28
+ # The input is the shortcut to the entry that will be expanded.
29
+ #
30
+ # @return [String or Array]
31
+ # ========================================================================= #
32
+ def self.menu(
33
+ i = :top
34
+ )
35
+ _ = i.to_s # .downcase # Keep it downcased. # No longer downcase as of February 2022.
36
+ _ = ensure_main_encoding(_) # Use a uniform encidong.
37
+ local_entry = local_menu(_) # Query for the local menu-entries.
38
+ # ======================================================================= #
39
+ # The following comparison means that we did not find anything in the
40
+ # local menu.
41
+ # ======================================================================= #
42
+ if _ != local_entry
43
+ return local_entry # Then this must be a local entry.
44
+ end
45
+ # ======================================================================= #
46
+ # Next, check if we have a university entry. Since as of 20.04.2019,
47
+ # if we are on roebe, and we have encounter a registered entry for
48
+ # the given input then we will use that one instead.
49
+ # ======================================================================= #
50
+ if ::BeautifulUrl.is_on_roebe?
51
+ begin
52
+ require 'studium/toplevel_methods/return_remote_homepage_of_this_lecture.rb'
53
+ if Studium.is_this_url_registered?(_)
54
+ return Studium.return_remote_homepage_of_this_lecture(_)
55
+ end
56
+ rescue LoadError
57
+ end
58
+ end
59
+ # ======================================================================= #
60
+ # Delegate towards science_menu() next:
61
+ # ======================================================================= #
62
+ science_entry = science_menu(_)
63
+ if _ != science_entry
64
+ return science_entry
65
+ end
66
+ # ======================================================================= #
67
+ # Delegate towards pdf_books_menu() next:
68
+ # ======================================================================= #
69
+ entry = pdf_books_menu(_)
70
+ if _ != entry
71
+ return entry
72
+ end
73
+ # ======================================================================= #
74
+ # Delegate towards video_menu() next:
75
+ # ======================================================================= #
76
+ video_entry = video_menu(_)
77
+ if _ != video_entry
78
+ return video_entry
79
+ end
80
+ # ======================================================================= #
81
+ # Delegate towards new_university_menu() next:
82
+ # ======================================================================= #
83
+ new_university_entry = new_university_menu(_)
84
+ if _ != new_university_entry
85
+ return new_university_entry
86
+ end
87
+ # ======================================================================= #
88
+ # Delegate towards university_menu() next:
89
+ # ======================================================================= #
90
+ university_entry = university_menu(_)
91
+ if _ != university_entry
92
+ return university_entry
93
+ end
94
+ # ======================================================================= #
95
+ # Delegate towards jobs_menu() next:
96
+ # ======================================================================= #
97
+ jobs_entry = jobs_menu(_)
98
+ if _ != jobs_entry
99
+ return jobs_entry
100
+ end
101
+ traditional_entry = traditional_menu(_)
102
+ if traditional_entry.is_a? Array # Improve on the Array in this case.
103
+ traditional_entry.map! {|inner_entry|
104
+ traditional_menu(inner_entry)
105
+ }
106
+ return traditional_entry # return our assigned return value here.
107
+ end
108
+ if !(traditional_entry == i)
109
+ return traditional_entry
110
+ else
111
+ return i
112
+ end
113
+ end; self.instance_eval { alias expand menu } # === BeautifulUrl.expand
114
+ self.instance_eval { alias url menu } # === BeautifulUrl.url
115
+ self.instance_eval { alias sanitize_url menu } # === BeautifulUrl.sanitize_url
116
+ self.instance_eval { alias sanitize_this_input menu } # === BeautifulUrl.sanitize_this_input
117
+
118
+ end
119
+
120
+ if __FILE__ == $PROGRAM_NAME
121
+ puts BeautifulUrl.menu
122
+ # puts BeautifulUrl.menu('javascripttasks')
123
+ end
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'beautiful_url/toplevel_methods/misc.rb'
6
+ # =========================================================================== #
7
+ module BeautifulUrl
8
+
9
+ require 'beautiful_url/project/project.rb'
10
+
11
+ # ========================================================================= #
12
+ # === BeautifulUrl.create_json_file
13
+ # ========================================================================= #
14
+ def self.create_json_file
15
+ begin
16
+ require 'case_parser'
17
+ rescue LoadError; end
18
+ what = "{\n".dup # The opening tag.
19
+ array = %w(
20
+ jobs_menu.rb
21
+ local_menu.rb
22
+ moodle_menu.rb
23
+ science_menu.rb
24
+ traditional_menu.rb
25
+ university_menu.rb
26
+ video_menu.rb
27
+ )
28
+ array.each {|this_rb_file|
29
+ absolute_path = ::BeautifulUrl.project_base_dir?+'/toplevel_methods/'+this_rb_file
30
+ array = CaseParser.parse(absolute_path)
31
+ array.each {|this_entry_in_the_array|
32
+ original_value = this_entry_in_the_array.dup
33
+ next if this_entry_in_the_array =~ /^exam\d{1,2}/ # 'exam30' since this is special.
34
+ next if this_entry_in_the_array =~ /^nexam/ # 'nexam' since this is special.
35
+ next if this_entry_in_the_array =~ /^next(_|-)?exam/ # This as well.
36
+ return_value = BeautifulUrl[original_value]
37
+ if original_value == return_value # Faulty - ignore then.
38
+ else
39
+ what << "\"#{this_entry_in_the_array}\": \"#{return_value}\",\n"
40
+ end
41
+ }
42
+ }
43
+ what << '}' # The closing tag.
44
+ into = 'beautiful_url.json'
45
+ begin
46
+ require 'save_file'
47
+ rescue LoadError; end
48
+ puts 'Storing into `'+into+'`.'
49
+ SaveFile.write_what_into(what, into)
50
+ end
51
+
52
+ # ========================================================================= #
53
+ # === BeautifulUrl.home_dir?
54
+ #
55
+ # This method will simply return the home directory of the user at hand.
56
+ # ========================================================================= #
57
+ def self.home_dir?
58
+ "#{ENV['HOME']}/"
59
+ end
60
+
61
+ # ========================================================================= #
62
+ # === BeautifulUrl.file_passwords
63
+ # ========================================================================= #
64
+ def self.file_passwords
65
+ require 'beautiful_url/toplevel_methods/local_menu.rb'
66
+ return ::BeautifulUrl.local_menu(:local_password_file)
67
+ end
68
+
69
+ end
70
+
71
+ if __FILE__ == $PROGRAM_NAME
72
+ puts BeautifulUrl.file_passwords
73
+ end
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # Code stored here will specifically handle moodle-related links. This
6
+ # is mostly for university-related content, but may also include other
7
+ # sites that make use of moodle.
8
+ #
9
+ # Do note that since as of the year 2020, this file has been mostly
10
+ # superceded by code stored in the Studium gem. The latter can
11
+ # obtain all moodle-entries of every registered lecture automatically,
12
+ # so it is MUCH better than the handwritten and hardcoded approach
13
+ # used in the file here.
14
+ #
15
+ # The file here will still be kept for legacy-reasons mostly, but will
16
+ # be quite minimal - there is one small qualitative difference, though,
17
+ # in the sense that we can use shortcuts here, which the Studium gem
18
+ # can not do. So it is not 100% legacy code; only about 90% legacy
19
+ # code really.
20
+ # =========================================================================== #
21
+ # require 'beautiful_url/toplevel_methods/moodle_menu.rb'
22
+ # =========================================================================== #
23
+ module BeautifulUrl
24
+
25
+ # ========================================================================= #
26
+ # === BeautifulUrl.moodle
27
+ # ========================================================================= #
28
+ def self.moodle(i = :default)
29
+ i = i.first if i.is_a? Array
30
+ i =
31
+ case i # case tag
32
+ # ======================================================================= #
33
+ # === moodle systembiologie
34
+ # ======================================================================= #
35
+ when /^301696(_|-| )?Grundlagen(_|-| )?der(_|-| )?Systembiologie$/i,
36
+ /^Grundlagen(_|-| )?der(_|-| )?Systembiologie$/i,
37
+ 'systembiologie', # moodle systembiologie
38
+ :default
39
+ 'https://moodle.univie.ac.at/course/view.php?id=88847' # 2018W
40
+ # ======================================================================= #
41
+ # === moodle "850110 Ausgewählte Kapitel aus der KTWW"
42
+ # ======================================================================= #
43
+ when /^850110(_|-| )?Ausgewählte(_|-| )?Kapitel(_|-| )?aus(_|-| )?der(_|-| )?KTWW$/i,
44
+ /^Ausgewählte(_|-| )?Kapitel(_|-| )?aus(_|-| )?der(_|-| )?KTWW$/i,
45
+ /^Ausgewählte(_|-| )?Kapitel$/i,
46
+ 'ktww', # moodle ktww
47
+ '2'
48
+ 'https://learn.boku.ac.at/course/view.php?id=17882' # 2018W
49
+ # ======================================================================= #
50
+ # === moodle "270087 Struktur und Dynamik von Biopolymeren"
51
+ # ======================================================================= #
52
+ when /^270087(_|-| )?Struktur(_|-| )?und(_|-| )?Dynamik(_|-| )?von(_|-| )?Biopolymeren$/i,
53
+ /^Struktur(_|-| )?und(_|-| )?Dynamik(_|-| )?von(_|-| )?Biopolymeren$/i,
54
+ 'biopolymere'
55
+ 'https://moodle.univie.ac.at/course/view.php?id=97035' # 2018W
56
+ # ======================================================================= #
57
+ # === moodle Allgemeine Botanik
58
+ # ======================================================================= #
59
+ when /^Allgemeine(_|-| )?Botanik$/i,
60
+ /^831135(_|-| )?Allgemeine(_|-| )?Botanik$/i,
61
+ 'botanik'
62
+ 'https://learn.boku.ac.at/course/view.php?id=17749' # 2018W
63
+ # ======================================================================= #
64
+ # === moodle chemie
65
+ # ======================================================================= #
66
+ when /^771100(_|-| )?Einführung(_|-| )?in(_|-| )?die(_|-| )?Chemie$/i,
67
+ /^Einführung(_|-| )?in(_|-| )?die(_|-| )?Chemie$/i,
68
+ 'chemie'
69
+ 'https://learn.boku.ac.at/course/view.php?id=17253' # 2018W
70
+ # ======================================================================= #
71
+ # === moodle elektrophorese
72
+ # ======================================================================= #
73
+ when /^270111(_|-| )?Elektrophoretische(_|-| )?und(_|-| )?Chromatographische(_|-| )?Trennmethoden$/i,
74
+ /^Elektrophoretische(_|-| )?und(_|-| )?Chromatographische(_|-| )?Trennmethoden$/i,
75
+ 'elektrophorese'
76
+ 'https://moodle.univie.ac.at/course/view.php?id=89895' # 2018W
77
+ # ======================================================================= #
78
+ # === moodle crispr
79
+ # ======================================================================= #
80
+ when /^322052(_|-| )?VO(_|-| )?Nukleinsäure(_|-| )?Therapeutika(_|-| |:)?(_|-| )?Antisense(_|-| |,)?(_|-| )?RNA(_|-| )?Interferenz(_|-| |,)?(_|-| )?CRISPR(_|-| )?(_|-| )?(_|-| )?M14$/i,
81
+ /^322052(_|-| )?Nukleinsäure(_|-| )?Therapeutika(_|-| |:)?(_|-| )?Antisense(_|-| |,)?(_|-| )?RNA(_|-| )?Interferenz(_|-| |,)?(_|-| )?CRISPR(_|-| )?(_|-| )?(_|-| )?M14$/i,
82
+ /^322052(_|-| )?Nukleinsäure(_|-| )?Therapeutika(_|-| |:)?(_|-| )?Antisense(_|-| |,)?(_|-| )?RNA(_|-| )?Interferenz(_|-| |,)?(_|-| )?CRISPR$/i,
83
+ /^Nukleinsäure(_|-| )?Therapeutika(_|-| |:)?(_|-| )?Antisense(_|-| |,)?(_|-| )?RNA(_|-| )?Interferenz(_|-| |,)?(_|-| )?CRISPR$/i,
84
+ /^Nukleinsäure(_|-| )?Therapeutika$/i,
85
+ 'crispr', # moodle crispr
86
+ 'default','main',
87
+ '1'
88
+ 'https://moodle.univie.ac.at/course/view.php?id=91738' # 2018W
89
+ # ======================================================================= #
90
+ # === moodle "791318 Animal cell culture (in Eng.)"
91
+ # ======================================================================= #
92
+ when /^791318(_|-| )?Animal(_|-| )?cell(_|-| )?culture(_|-| )?\(?in(_|-| )?Eng\.?\)?$/i,
93
+ /^791318(_|-| )?Animal(_|-| )?cell(_|-| )?culture$/i,
94
+ /^Animal(_|-| )?cell(_|-| )?culture$/i,
95
+ 'cellculture' # moodle cellculture
96
+ 'https://learn.boku.ac.at/course/view.php?id=17371' # 2018W
97
+ # ======================================================================= #
98
+ # === moodle RNA
99
+ # ======================================================================= #
100
+ when /^301652(_|-| )?VO(_|-| )?Molekularbiologie(_|-| )?der(_|-| )?RNA$/i,
101
+ /^301652(_|-| )?Molekularbiologie(_|-| )?der(_|-| )?RNA$/i,
102
+ /^Molekularbiologie(_|-| )?der(_|-| )?RNA$/i,
103
+ 'RNA' # moodle RNA
104
+ 'https://moodle.univie.ac.at/course/view.php?id=72900' # 2018S
105
+ # ======================================================================= #
106
+ # === moodle "Bodenkunde (AW)"
107
+ # ======================================================================= #
108
+ when /^Bodenkunde(_|-| )?\(?AW\)?$/i,
109
+ 'bodenkunde',
110
+ '3'
111
+ 'https://learn.boku.ac.at/course/view.php?id=9941' # 2016S
112
+ else
113
+ i # else return the input unmodified (save for changing Array into String)
114
+ end
115
+ i
116
+ end
117
+
118
+ # ========================================================================= #
119
+ # === BeautifulUrl.is_included_in_moodle?
120
+ #
121
+ # This method will return a Boolean - true if the input argument is
122
+ # included in the moodle-listing; and false otherwise.
123
+ # ========================================================================= #
124
+ def self.is_included_in_moodle?(i)
125
+ i = i.first if i.is_a? Array
126
+ original_input = i.dup
127
+ possibly_modified_input = moodle(original_input)
128
+ !(possibly_modified_input == original_input)
129
+ end
130
+
131
+ end
132
+
133
+ if __FILE__ == $PROGRAM_NAME
134
+ puts BeautifulUrl.moodle
135
+ end