From 027216a087bcf7918988d16f07189a969a302f6f Mon Sep 17 00:00:00 2001 From: Matthieu Date: Sun, 9 Apr 2017 21:50:58 +0200 Subject: [PATCH] V : 0.11.4 --- Changelog.md | 3 +- MangaScrap.rb | 90 ++----- README.md | 40 +-- migration/0.9.X_to_1.0.x.txt | 19 -- sources/{Classes => }/DB/Manga_data.rb | 22 +- sources/{Classes => }/DB/Manga_database.rb | 0 sources/{Classes => }/DB/Params.rb | 0 sources/{Classes => }/Download/mangafox.rb | 0 sources/{Classes => }/DownloadDisplay.rb | 0 sources/api/README.md | 25 ++ sources/api/mangas.rb | 136 ++++++++++ sources/api/other.rb | 18 ++ sources/api/output.rb | 99 ++++++++ sources/api/params.rb | 14 ++ sources/{Classes => }/html/html.rb | 22 +- sources/{Classes => }/html/html_buffer.rb | 0 sources/init.rb | 57 +++++ .../instructions/Instructions_exec.rb | 170 +++++++------ .../instructions/Manga_data_filter.rb | 0 .../instructions/Parsers/Data_parser.rb | 0 .../instructions/Parsers/File_parser.rb | 0 .../Parsers/Instruction_parser.rb | 11 +- .../instructions/Parsers/Query_Parser.rb | 0 sources/instructions/basic_instructions.rb | 232 ------------------ sources/instructions/params.rb | 2 +- sources/{Classes => }/instructions/query.rb | 0 {utils => sources/templates/text}/help.txt | 0 .../templates/text}/params.txt | 0 sources/templates/text/version.txt | 1 + .../templates/web}/chapter_index_template.css | 0 .../web}/chapter_index_template.html | 0 .../templates/web}/chapter_index_template.js | 0 .../templates/web}/chapter_template.css | 0 .../templates/web}/chapter_template.html | 0 .../templates/web}/chapter_template.js | 0 .../templates/web}/manga_index_template.css | 0 .../templates/web}/manga_index_template.html | 0 .../templates/web}/manga_index_template.js | 0 .../web}/manga_updated_index_template.css | 0 .../web}/manga_updated_index_template.html | 0 sources/utils/utils_manga.rb | 1 + utils/version.txt | 1 - 42 files changed, 543 insertions(+), 420 deletions(-) delete mode 100644 migration/0.9.X_to_1.0.x.txt rename sources/{Classes => }/DB/Manga_data.rb (81%) rename sources/{Classes => }/DB/Manga_database.rb (100%) rename sources/{Classes => }/DB/Params.rb (100%) rename sources/{Classes => }/Download/mangafox.rb (100%) rename sources/{Classes => }/DownloadDisplay.rb (100%) create mode 100644 sources/api/README.md create mode 100644 sources/api/mangas.rb create mode 100644 sources/api/other.rb create mode 100644 sources/api/output.rb create mode 100644 sources/api/params.rb rename sources/{Classes => }/html/html.rb (91%) rename sources/{Classes => }/html/html_buffer.rb (100%) rename sources/{Classes => }/instructions/Instructions_exec.rb (68%) rename sources/{Classes => }/instructions/Manga_data_filter.rb (100%) rename sources/{Classes => }/instructions/Parsers/Data_parser.rb (100%) rename sources/{Classes => }/instructions/Parsers/File_parser.rb (100%) rename sources/{Classes => }/instructions/Parsers/Instruction_parser.rb (88%) rename sources/{Classes => }/instructions/Parsers/Query_Parser.rb (100%) delete mode 100644 sources/instructions/basic_instructions.rb rename sources/{Classes => }/instructions/query.rb (100%) rename {utils => sources/templates/text}/help.txt (100%) rename {templates => sources/templates/text}/params.txt (100%) create mode 100644 sources/templates/text/version.txt rename {templates => sources/templates/web}/chapter_index_template.css (100%) rename {templates => sources/templates/web}/chapter_index_template.html (100%) rename {templates => sources/templates/web}/chapter_index_template.js (100%) rename {templates => sources/templates/web}/chapter_template.css (100%) rename {templates => sources/templates/web}/chapter_template.html (100%) rename {templates => sources/templates/web}/chapter_template.js (100%) rename {templates => sources/templates/web}/manga_index_template.css (100%) rename {templates => sources/templates/web}/manga_index_template.html (100%) rename {templates => sources/templates/web}/manga_index_template.js (100%) rename {templates => sources/templates/web}/manga_updated_index_template.css (100%) rename {templates => sources/templates/web}/manga_updated_index_template.html (100%) delete mode 100644 utils/version.txt diff --git a/Changelog.md b/Changelog.md index 4d1c6fb..2912fe1 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,7 @@ ### Changelog : -0.11.3 : debugs mineurs + implémentation de scripts pour faire les migrations plus facilement
+0.11.4 : added an API and instructions on how to use it, it will be used for the GUI
+0.11.3 : small bug fixes + implemented scripts to allow faster migrations / updates
0.11.2 : implemented the 'data' instruction
0.11.1 : implemented the 'details' and 'fast-update' instructions + debugged the delete-diff + the directory system should be compatible with Windows
0.11.0 : the argument management completely changed and is now much easier to use ( added instructions and a new way to use MangaScrap ) + the html was heavily optimised + added a management of bad gem loads + changed the way mangas are identified to allow the scrap of multiple sites
diff --git a/MangaScrap.rb b/MangaScrap.rb index 817e9f4..18bd459 100755 --- a/MangaScrap.rb +++ b/MangaScrap.rb @@ -1,76 +1,40 @@ #!/usr/bin/env ruby # coding: utf-8 -# thanks for downloading MangaScrap ! -# if you have a question, please go here : -# https://github.com/Hellfire01/MangaScrap -# -# Note : -# MangaScrap will install it's databases and templates -# in ~/.MangaScrap -# -# MangaScrap's return values :+ -# 0 : good -# 1 : fatal error ( ruby native code exceptions ) -# 2 : db error -# 3 : connection error -# 4 : unexpected error ( not yet managed stuff ) -# 5 : argument error -# 6 : gem error +=begin -require 'singleton' -require 'open-uri' -require 'pp' +thanks for downloading MangaScrap ! +if you have a question, please go here : +https://github.com/Hellfire01/MangaScrap -def load_gem(gem) - begin - require gem - rescue Exception => e - puts '' - puts "exception while trying to load #{gem}, please follow the installation instructions in the install directory" - puts 'message is : ' + e.message - puts 'please note that a ruby update may require a re-download of the gems' - puts '' - exit 6 - end -end +Note : +MangaScrap will install it's databases and templates +in ~/.MangaScrap/ -# gems -load_gem 'colorize' -load_gem 'nokogiri' -load_gem 'sqlite3' +MangaScrap's return values : +0 : good +1 : fatal error ( ruby native code exceptions ) +2 : db error +3 : connection error +4 : unexpected error ( not yet managed stuff ) +5 : argument error +6 : gem error -# files -require_relative 'sources/init' -require_relative 'sources/scan/scan' -require_relative 'sources/scan/scan_utils' -require_relative 'sources/instructions/delete_diff' -require_relative 'sources/instructions/basic_instructions' -require_relative 'sources/instructions/params' -require_relative 'sources/instructions/redl' -require_relative 'sources/utils/utils_file' -require_relative 'sources/utils/utils_args' -require_relative 'sources/utils/utils_co' -require_relative 'sources/utils/utils_manga' -require_relative 'sources/utils/utils_html' -require_relative 'sources/utils/utils_debug' -require_relative 'sources/Classes/html/html' -require_relative 'sources/Classes/html/html_buffer' -require_relative 'sources/Classes/Download/mangafox' -require_relative 'sources/Classes/DownloadDisplay' -require_relative 'sources/Classes/instructions/Parsers/Instruction_parser' -require_relative 'sources/Classes/instructions/Parsers/Data_parser' -require_relative 'sources/Classes/instructions/Parsers/Query_Parser' -require_relative 'sources/Classes/instructions/Parsers/File_parser' -require_relative 'sources/Classes/instructions/query' -require_relative 'sources/Classes/instructions/Instructions_exec' -require_relative 'sources/Classes/instructions/Manga_data_filter' -require_relative 'sources/Classes/DB/Manga_data' -require_relative 'sources/Classes/DB/Manga_database' -require_relative 'sources/Classes/DB/Params' +API : +should you want to use your own gui or use MangaScrap your own way, +the api can be found in ./sources/api/ + +=end +require_relative 'sources/init' initialize_mangascrap +# if ARGV.size == 0 +# note : instruction_exec posses this comparison args = Instructions_exec.new args.run +# else +# gui +# end + diff --git a/README.md b/README.md index 2f9e93b..9507bb7 100644 --- a/README.md +++ b/README.md @@ -4,30 +4,40 @@ MangaScrap is a Ruby based program that will allow you to download your mangas a It posses a database that allows it to know what chapters where not downloaded yet
Unlike other manga downloaders, it creates a local website on your computer allowing you to browse your mangas offline

- + ### basic usage : -`./MangaScrap add link [link]`
-Will add a manga to follow to the database
-`./MangaScrap`
-Will update all mangas within the database
-`./MangaScrap download link [link]`
-Will add the manga to the database and then download it
+How to add and download a manga
+ +- `./MangaScrap add link [link]`
+Will add a manga to follow to the database +- `./MangaScrap`
+Will update all mangas within the database +- `./MangaScrap download link [link]`
+Will add the manga to the database and then download it +
+
### configuration + MangaScrap has configurable parameters witch will allow you to configure the way it work to fit your needs
-
-`./MangaScrap params list`
-Shows all the parameters and there values
-`./MangaScrap params set [param] [value]`
+- `./MangaScrap params list`
+Shows all the parameters and there values +- `./MangaScrap params set [param] [value]`
Allow you to change a parameter

### notes : -`./MangaScrap help`
+ +- `./MangaScrap help`
Displays instructions
+- The program will download all mangas in ~/Documents/mangas/ by default ( should the path not exist, it will be created automatically )
+- Currently MangaScrap only manages mangafox but it is planned to do much more in the near future
+- The dev branch of MangaScrap is on [gitlab](https://gitlab.com/Hellfire01/MangaScrapp) +

-The program will download all mangas in ~/Documents/mangas/ by default
-( should the path not exist, it will be created automatically )
-Currently MangaScrap only manages mangafox but it is planned to do much more in the near future
+ +### API : + +If you wish to add instructions / a gui / ... to MangaScrap, please check [here](sources/api/README.md).
diff --git a/migration/0.9.X_to_1.0.x.txt b/migration/0.9.X_to_1.0.x.txt deleted file mode 100644 index 194aa08..0000000 --- a/migration/0.9.X_to_1.0.x.txt +++ /dev/null @@ -1,19 +0,0 @@ -1 - Delete your params DB ( please note all important information such as mangapath before doing so if you have changed any parameter ) -rm ~/.MangaScrap/db/params.db - -2 - Update your manga.db -sqlite3 ~/.MangaScrap/db/manga.db -ALTER TABLE manga_list ADD html_name TEXT; -ALTER TABLE manga_list ADD alternative_names NTEXT; -ALTER TABLE manga_list ADD rank int; -ALTER TABLE manga_list ADD rating int; -ALTER TABLE manga_list ADD rating_max int; -.exit; - -3 - install new dependency -sudo gem install colorize - -4 - Update your database and the site -./MangaScrap -l > tmp_manga_list.txt -./MangaScrap -da -f tmp_manga_list.txt -rm tmp_manga_list.txt diff --git a/sources/Classes/DB/Manga_data.rb b/sources/DB/Manga_data.rb similarity index 81% rename from sources/Classes/DB/Manga_data.rb rename to sources/DB/Manga_data.rb index f12e175..1048835 100644 --- a/sources/Classes/DB/Manga_data.rb +++ b/sources/DB/Manga_data.rb @@ -103,6 +103,7 @@ def is_site_compatible?(display) end public + # returns an array of the sites that MangaScrap currently manages def self.get_compatible_sites ['http://mangafox.me/'] end @@ -113,9 +114,11 @@ def to_s ', site = ' + ((@site == nil) ? '/' : '"' + @site + '"') end + # used to get an array containing the volume / chapter / page values from a link + # will exit if the resolve method was not called before and did not return true def extract_values_from_link(link) unless @status - critical_error('extract_values_from_link function was called when the data class was not resolved or invalid') + critical_error('the extract_values_from_link method was called when the data class was not resolved or invalid') end case @site when 'http://mangafox.me/' @@ -125,9 +128,11 @@ def extract_values_from_link(link) end end + # returns the class used to download the manga + # will exit if the resolve method was not called before and did not return true def get_download_class unless @status - critical_error('the download class was required when the data class is not ready') + critical_error('the get_download_class method was called when the data class was not resolved or invalid') end begin case @site @@ -145,8 +150,10 @@ def get_download_class end # the function resolve will try to complete the missing information - # for that it will connect to the database and check or look online - # unless get_data_in_db + # for that it will connect to the database and check or look online unless get_data_in_db + # please note that the function will exit if the constructor was not called with the good arguments + # connect = bool, determines if the class can try to use internet if it could not find in the database + # display = bool, used to allow writing on the standard output or not def resolve(connect, display) if @status return true @@ -192,7 +199,12 @@ def resolve(connect, display) end end - # if data = nil => the manga is not in the database + # the constructor takes multiple arguments but they should not all be given at once unless the data comes from the database + # id = int / nil, is the id used in the database + # name = string / nil, is the name used in the url of the manga + # site = string / nil, is the name of the website hosting the manga + # link = string / nil, is the url of the manga + # data = array of elements / nil, the array contains the line of the manga in the database def initialize(id, name, site, link, data) @name = name @site = site diff --git a/sources/Classes/DB/Manga_database.rb b/sources/DB/Manga_database.rb similarity index 100% rename from sources/Classes/DB/Manga_database.rb rename to sources/DB/Manga_database.rb diff --git a/sources/Classes/DB/Params.rb b/sources/DB/Params.rb similarity index 100% rename from sources/Classes/DB/Params.rb rename to sources/DB/Params.rb diff --git a/sources/Classes/Download/mangafox.rb b/sources/Download/mangafox.rb similarity index 100% rename from sources/Classes/Download/mangafox.rb rename to sources/Download/mangafox.rb diff --git a/sources/Classes/DownloadDisplay.rb b/sources/DownloadDisplay.rb similarity index 100% rename from sources/Classes/DownloadDisplay.rb rename to sources/DownloadDisplay.rb diff --git a/sources/api/README.md b/sources/api/README.md new file mode 100644 index 0000000..49225dd --- /dev/null +++ b/sources/api/README.md @@ -0,0 +1,25 @@ +# MangaScrap's API + +All of MangaScrap passes through the methods that are in the api directory
+Here you can use MangaScrap directly to ( example ) build your own GUI or your own instruction
+Please note that these methods are called from the argument parser witch is at ./sources/instructions/Instructions_exec.rb +( you will have to add the call to your instruction there and follow the directions there )
+ +There are 4 files containing the API : +- _mangas.rb_
+Allows you to manipulate the mangas database ( add / update / download / ... )
+**methods**: add, update, download, data, clear, delete +- _oher.rb_
+contains any part of the API that could not be sorted as they are too small to justify having a file of their own
+**methods**: html +- _ouput.rb_
+Reading from the database
+**methods**: details, output, help and version +- _params_
+Configuring MangaScrap using it's parameters
+**methods**: get_params_list, set_param, reset_params + +**Important** :
+To manipulate mangas, MangaScrap uses the Manga_Data class witch you can find here : ./sources/DB/Manga_data.rb.
+The class works by giving to it's constructor the name and site or the link and the calling the **resolve** method witch +will return true or false depending on if it could find / use the given information. diff --git a/sources/api/mangas.rb b/sources/api/mangas.rb new file mode 100644 index 0000000..4d94452 --- /dev/null +++ b/sources/api/mangas.rb @@ -0,0 +1,136 @@ +# This file contains all the instructions that alter the manga database +# add / update / download / delete / clear / todo + +# whenever a user confirmation is required, this function is called +# message = message that is displayed +# mangas = array of Manga_Data +def require_confirmation (message, mangas = nil) + puts message + if mangas != nil + output(mangas) + puts '' + end + puts "Write 'YES' to continue" + ret = STDIN.gets.chomp + puts '' + if ret == 'YES' || ret == 'Yes' || ret == 'yes' || ret == 'Y' || ret == 'y' + true + else + false + end +end + +# adds all the mangas to the database +# mangas = array of Manga_Data where status = true && in_db = false +# generate_html = bool indicating if Y/N must generate the html of the mangas +def add(mangas, generate_html = false) + puts 'adding ' + mangas.size.to_s + ' element(s) to database' + html = HTML.new + mangas.each do |manga| + dw = manga.get_download_class + if dw == nil + next + end + if generate_html + html.generate_chapter_index(manga, false) + end + end + html.generate_index if generate_html + puts 'done' +end + +# updates all mangas +# mangas = array of Manga_Data where status = true && in_db = true +# todo_only = bool, if true, only the _todo pages / chapters are downloaded +# fast_update = bool, if true, the update function will ignore all mangas with the 'Completed' status +def update(mangas, todo_only = false, fast_update = false) + html = HTML.new + params = Params.instance.get_params + if fast_update + mangas = mangas.reject{|manga| manga.data[8] == 'Completed'} + end + puts 'updating ' + mangas.size.to_s + ' element(s)' + mangas.each do |manga| + dw = manga.get_download_class + if dw == nil + next + end + if todo_only + generate_html = dw.todo + else + generate_html = dw.update + end + if params[6] == 'true' + generate_html = (delete_diff(dw.get_links, manga) || generate_html) + end + html.generate_chapter_index(manga) if generate_html + end + html.generate_index + html.generate_updated + puts 'done' +end + +# adds and then updates all mangas +# mangas = array of Manga_Data where status = true && in_db = false +def download(mangas) + add(mangas) + puts '' + filter = Manga_data_filter.new(mangas) + mangas_prepared = filter.run(false, true) + update(mangas_prepared) +end + +# downloads the cover and description of every element and re-generates the html +# mangas = array of Manga_Data where status = true && in_db = true +def data(mangas) + puts 'downloading data of ' + mangas.size.to_s + ' element(s)' + html = HTML.new + mangas.each do |manga| + dw = manga.get_download_class + if dw == nil + next + end + dw.data + html.generate_chapter_index(manga, false) + end + html.generate_index + puts 'done' +end + +# delete all _todo elements from the manga list +# mangas = array of Manga_Data where status = true && in_db = true +def clear(mangas) + if require_confirmation('you are about to ' + 'delete'.red + ' all todo elements of the following element(s) :', manga_list) + db = Manga_database.instance + mangas.each do |manga| + db.clear_todo(manga) + end + puts 'deleted all todo elements' + else + puts 'did not delete anything' + end +end + +# deletes all the mangas of the list from the database +# mangas = array of Manga_Data where status = true && in_db = true +# delete_files = bool, if true, the files of the manga will also be deleted +def delete(manga_list, delete_files = true) + if require_confirmation('you are about to ' + 'delete'.red + ' the following element(s) from the database' + ((delete_files) ? + ' and '.yellow + 'all of the downloaded pages' : + ' but ' + 'not'.yellow + ' the downloaded files' ), manga_list) + db = Manga_database.instance + path = Params.instance.get_params[1] + manga_list.each do |manga| + db.delete_manga(manga) + if delete_files + site_dir = get_dir_from_site(manga.site) + delete_files(path + site_dir + 'html/' + manga.name, '.html') + delete_files(path + site_dir + 'mangas/' + manga.name, '.jpg') + end + end + puts 'deleted all elements' + HTML.new.generate_index + else + puts 'did not delete anything' + end +end diff --git a/sources/api/other.rb b/sources/api/other.rb new file mode 100644 index 0000000..c47a229 --- /dev/null +++ b/sources/api/other.rb @@ -0,0 +1,18 @@ +# this file contains all the methods that could not have their own file because there +# where too little of them +# html : html + +# ensures that the HTML class is correctly used to generate all the needed html +# mangas = array of Manga_Data where status = true +# should mangas be nil or empty, only the index will be updated +def html_manager(mangas) + html = HTML.new + if mangas != nil && mangas.size != 0 + mangas.each do |manga| + html.generate_chapter_index(manga, true) + end + end + html.generate_index + html.generate_updated + puts 'done' +end diff --git a/sources/api/output.rb b/sources/api/output.rb new file mode 100644 index 0000000..a35d053 --- /dev/null +++ b/sources/api/output.rb @@ -0,0 +1,99 @@ +# This file contains only instructions that read from the database to write on the terminal +# manga related : output / details +# others : version / help + +# displays the name + site of the mangas ( used to create manga list files ) +# mangas = array of Manga_Data +def output(mangas) + mangas.sort{|a, b| a.link <=> b.link}.each do |manga| + puts manga.name + ' ' + manga.site + end +end + +# infos is used to get all the available information on the manga from the database +# this includes traces and _todo +# mangas = array of Manga_Data where status = true and in_db = true +def details(mangas) + database = Manga_database.instance + mangas.sort{|a, b| a.link <=> b.link}.each do |manga| + puts 'Details for : ' + manga.name.yellow + puts '' + puts 'Web :'.yellow + puts 'HTML name : ' + manga.data[11] + puts 'Site : ' + manga.site + puts 'Link : ' + manga.link + puts 'Database id : ' + manga.id.to_s + puts 'Author : ' + manga.data[5] + puts 'Artist : ' + manga.data[6] + puts 'Type : ' + manga.data[7] + puts 'Status : ' + manga.data[8] + puts 'Genres : ' + manga.data[9] + puts 'Year : ' + manga.data[10].to_s + puts 'Traces :'.yellow + puts 'downloaded chapters : ' + traces = database.get_trace(manga) + puts 'volumes : ' + traces.map{|e| e[2]}.uniq.size.to_s + puts 'chapters : ' + traces.size.to_s + pages = traces.map{|e| e[5]} + if pages.include? nil + puts 'Error : '.red + 'at least one chapter has no page count value in the database, please use the ' + 'data-check'.green + ' instruction to correct this' + else + puts 'pages : ' + pages.reduce(:+) + end + puts 'Todo :'.yellow + todo = database.get_todo(manga).size + # todo : sort the todo and display it + if todo == 0 + puts 'there are no todo to download' + else + # todo : ensure that the todo elements do not accumulate + puts "there is a total of #{todo} todo(s) to download" + end + end +end + +# just displays the version of MangaScrap witch is contained in a file +def version + begin + file = File.new(__dir__ + '/../templates/text/version.txt', 'r') + line = file.gets + file.close + rescue => err + puts 'Error : '.red + 'could not open version.txt file' + puts err.message + err + end + puts 'MangaScrap version : ' + line +end + +# displays the help after reading it from a file and colorizing it ( if the option is enabled ) +def help + begin + file = File.open('sources/templates/text/help.txt', 'r') + content = file.read + content = content.gsub('_todo', 'todo') + instructions = %w(link id file query all add update fast-update download redl param version help list output delete delete-db details html todo clear todo reset set data) + instructions.each do |instruction| + content = content.gsub('[' + instruction + ']g', instruction.green).gsub('[' + instruction + ']y', instruction.yellow) + end + content = content.gsub('INSTRUCTIONS', 'INSTRUCTIONS'.red) + content = content.gsub('EXAMPLES', 'EXAMPLES'.red) + content = content.gsub('DESCRIPTION', 'DESCRIPTION'.red) + content = content.gsub('Warning !', 'Warning !'.red) + content = content.gsub('NOT', 'NOT'.red) + content = content.gsub('note :', 'note :'.magenta) + content = content.gsub('definition :', 'definition :'.magenta) + content = content.gsub('definitions :', 'definitions :'.magenta) + content = content.gsub('[data arguments compatible]', '[data arguments compatible]'.blue) + content = content.gsub('[own arguments]', '[own arguments]'.blue) + content = content.gsub('[in database]', '[in database]'.blue) + content = content.gsub('[not in database]', '[not in database]'.blue) + content = content.gsub('[elements required]', '[elements required]'.blue) + content = content.gsub('[data argument]', '[data argument]'.blue) + content = content.gsub('[data arguments]', '[data arguments]'.blue) + puts content + rescue Errno::ENOENT => e + puts 'could not open help file' + puts e.message + end +end diff --git a/sources/api/params.rb b/sources/api/params.rb new file mode 100644 index 0000000..f3c4169 --- /dev/null +++ b/sources/api/params.rb @@ -0,0 +1,14 @@ +# params related + +# returns all of the parameters in an array of [name, id, value] +def get_params_list + +end + +def set_param + +end + +def reset_params + +end diff --git a/sources/Classes/html/html.rb b/sources/html/html.rb similarity index 91% rename from sources/Classes/html/html.rb rename to sources/html/html.rb index b3a25a6..ae7e016 100644 --- a/sources/Classes/html/html.rb +++ b/sources/html/html.rb @@ -168,13 +168,13 @@ def copy_html_related_files(site) dir_create(@dir + 'html/css/') dir_create(@dir + 'html/js/') # css - file_copy(__dir__ + '/../../../templates/chapter_index_template.css', @dir + '/html/css/chapter_index.css') - file_copy(__dir__ + '/../../../templates/chapter_template.css', @dir + '/html/css/chapter.css') - file_copy(__dir__ + '/../../../templates/manga_index_template.css', @dir + '/html/css/manga_index.css') - file_copy(__dir__ + '/../../../templates/manga_updated_index_template.css', @dir + '/html/css/manga_updated_index.css') + file_copy(__dir__ + '/../templates/web/chapter_index_template.css', @dir + '/html/css/chapter_index.css') + file_copy(__dir__ + '/../templates/web/chapter_template.css', @dir + '/html/css/chapter.css') + file_copy(__dir__ + '/../templates/web/manga_index_template.css', @dir + '/html/css/manga_index.css') + file_copy(__dir__ + '/../templates/web/manga_updated_index_template.css', @dir + '/html/css/manga_updated_index.css') # js - file_copy(__dir__ + '/../../../templates/chapter_index_template.js', @dir + '/html/js/chapter_index.js') - file_copy(__dir__ + '/../../../templates/chapter_template.js', @dir + '/html/js/chapter.js') + file_copy(__dir__ + '/../templates/web/chapter_index_template.js', @dir + '/html/js/chapter_index.js') + file_copy(__dir__ + '/../templates/web/chapter_template.js', @dir + '/html/js/chapter.js') $copied_js_css << site end end @@ -200,7 +200,7 @@ def generate_chapter_index(manga_data, index = true) @index_path = @dir + 'index.html' #todo : manage sites @traces = get_traces(manga_data) dir_create(@path_html) - template = File.open('templates/chapter_index_template.html').read + template = File.open('sources/templates/web/chapter_index_template.html').read template = template.gsub('#####name#####', @manga_name) template = template.gsub('#####description#####', @manga_data[2].gsub("\n", '
')) template = template.gsub('#####site#####', html_a_buffer(@manga_data[4])) @@ -218,7 +218,7 @@ def generate_chapter_index(manga_data, index = true) template = chapter_list_to_a_list(template).gsub('#', '%23') File.open(@path_html + '.html', 'w') {|f| f.write(template)} if index - @chapter_template = File.open('templates/chapter_template.html').read + @chapter_template = File.open('sources/templates/web/chapter_template.html').read html_generate_chapters(manga_data) end end @@ -232,10 +232,10 @@ def generate_index sites.each do |site| @dir = @params[1] + get_dir_from_site(site) copy_html_related_files(site) - template = File.open('templates/manga_index_template.html').read + template = File.open('sources/templates/web/manga_index_template.html').read template = template.gsub('#####list#####', html_get_data(site)) File.open(@dir + 'index.html', 'w') {|f| f.write(template)} - js = File.open('templates/manga_index_template.js').read + js = File.open('sources/templates/web/manga_index_template.js').read js = js.gsub('#####tab#####', index_js_data(site)) File.open(@dir + 'html/js/manga_index.js', 'w') {|f| f.write(js)} end @@ -258,7 +258,7 @@ def generate_updated sites.each do |site| @dir = @params[1] + get_dir_from_site(site) copy_html_related_files(site) - template = File.open('templates/manga_updated_index_template.html').read + template = File.open('sources/templates/web/manga_updated_index_template.html').read template = template.gsub('#####list#####', html_get_data(site, true)) File.open(@dir + 'index_updated.html', 'w') {|f| f.write(template)} end diff --git a/sources/Classes/html/html_buffer.rb b/sources/html/html_buffer.rb similarity index 100% rename from sources/Classes/html/html_buffer.rb rename to sources/html/html_buffer.rb diff --git a/sources/init.rb b/sources/init.rb index 1f45c44..5b30699 100644 --- a/sources/init.rb +++ b/sources/init.rb @@ -1,5 +1,62 @@ #anything that needs to be done before the rest of MangaScrap is executed is placed here + +def load_gem(gem) + begin + require gem + rescue Exception => e + puts '' + puts "exception while trying to load #{gem}, please follow the installation instructions in the install directory" + puts 'message is : ' + e.message + puts 'please note that a ruby update may require a re-download of the gems' + puts '' + exit 6 + end +end + +def load_all_gems + require 'singleton' + require 'open-uri' + require 'pp' + load_gem 'colorize' + load_gem 'nokogiri' + load_gem 'sqlite3' +end + +def load_relative_files + require_relative 'scan/scan' + require_relative 'scan/scan_utils' + require_relative 'api/mangas' + require_relative 'api/other' + require_relative 'api/output' + require_relative 'api/params' + require_relative 'instructions/delete_diff' + require_relative 'instructions/params' + require_relative 'instructions/redl' + require_relative 'utils/utils_file' + require_relative 'utils/utils_args' + require_relative 'utils/utils_co' + require_relative 'utils/utils_manga' + require_relative 'utils/utils_html' + require_relative 'utils/utils_debug' + require_relative 'html/html' + require_relative 'html/html_buffer' + require_relative 'Download/mangafox' + require_relative 'DownloadDisplay' + require_relative 'instructions/Parsers/Instruction_parser' + require_relative 'instructions/Parsers/Data_parser' + require_relative 'instructions/Parsers/Query_Parser' + require_relative 'instructions/Parsers/File_parser' + require_relative 'instructions/query' + require_relative 'instructions/Instructions_exec' + require_relative 'instructions/Manga_data_filter' + require_relative 'DB/Manga_data' + require_relative 'DB/Manga_database' + require_relative 'DB/Params' +end + def initialize_mangascrap + load_all_gems + load_relative_files Struct.new('Arg', :name, :sub_args, :nb_args, :does_not_need_args?) Struct.new('Sub_arg', :name, :nb_args) Struct.new('Updated', :name, :downloaded) diff --git a/sources/Classes/instructions/Instructions_exec.rb b/sources/instructions/Instructions_exec.rb similarity index 68% rename from sources/Classes/instructions/Instructions_exec.rb rename to sources/instructions/Instructions_exec.rb index c041533..ebbfeaf 100644 --- a/sources/Classes/instructions/Instructions_exec.rb +++ b/sources/instructions/Instructions_exec.rb @@ -1,5 +1,21 @@ -# class used for the argument management -# it returns the required commands on success and nil on failure +=begin +This class parses the ARGV to extract all of the instructions MangaScrap will use +To add your own instruction, you need to add your own block respecting this format in the init_parser method : + +@parser.on name_of_your_instruction do |args| + buff = get_valid_data(name_of_your_instruction_for_error_display, require_internet?, args, error_if_invalid?) + html_manager(buff) +end + +note : you can use multiple names +note : error_if_invalid? is used to say if your function NEEDS at least 1 valid Manga_Data ( no invalid ones will be given ) + +important : should your method use it's own special arguments, add this line in the init : +@parser.jump_when(name_of_your_instruction, number_of_arguments) +this will allow MangaScrap to know that these arguments should not be parsed as instructions + +=end + class Instructions_exec attr_reader :data_to_prepare private @@ -12,46 +28,45 @@ def required_arguments(instruction, args) end end + # returns a pre-configured parser for the data arguments + # id needs 2 arguments : name ( args[0] and site args[1] ) + # link needs one argument : link ( args[0] ) + # File parser uses one argument : file_name ( args[0] ) and directly outputs it's content in @data_to_prepare + # query takes one argument : query witch is the parsed to extract the required mangas + # all does not use any arguments and gets everything from the database def get_data_parser(instruction) parser = Data_parser.new(instruction) - # id needs 2 arguments : name ( args[0] and site args[1] ) parser.on('id', 2) do |args| data = Manga_data.new(nil, args[0], args[1], nil, nil) @data_to_prepare << data end - # link needs one argument : link ( args[0] ) parser.on('link', 1) do |args| link = args[0] - if link.size != 0 && link[link.size - 1] == '/' - # this ensures that all links do not finish by a '/' + if link.size != 0 && link[link.size - 1] == '/' # this ensures that all links do not finish by a '/' link = link.chomp('/') end data = Manga_data.new(nil, nil, nil, link, nil) @data_to_prepare << data end - # File parser uses args[0] as file name and directly outputs it's - # content in @data_to_prepare parser.on('file', 1) do |args| e = File_parser.new(args[0], @data_to_prepare) unless e.good puts 'ignoring file instruction'.yellow end end - # query - parser.on('query', 1) do |args| # <====================================================== + parser.on('query', 1) do |args| # <======================================================== currently a placeholder puts 'query is currently a placeholder' # query = Query_Manager.new # data = query.run(args[0]) end - # all does not use any arguments - # even tho the elements from the database are valid, they are sent to - # @data_to_prepare to avoid duplicates parser.on('all', 0) do || @data_to_prepare += Manga_database.instance.get_manga_list end parser end + # this method first calls the data arguments parser then filters all the Manga_Data classes that returned false on + # resolve and finally returns the validated Manga_Data classes def get_valid_data(function, connection, args, error_if_no_elements = true) tmp = args tmp = tmp.join(' ') @@ -61,19 +76,77 @@ def get_valid_data(function, connection, args, error_if_no_elements = true) ret = filter.run(connection, true) @data_to_prepare.clear if ret.size == 0 && error_if_no_elements - puts 'Warning : '.yellow + 'ignoring instruction ' + '['.yellow + function + ' ' + - tmp + ']'.yellow + '. Reason is : ' + 'no elements to use'.yellow + puts 'Warning : '.yellow + 'ignoring instruction ' + '['.yellow + function + ' ' + tmp + ']'.yellow + + '. Reason is : ' + 'no elements to use'.yellow end ret end + # used to prepare the parser, all of the instructions that are understood by MangaScrap are in these methods + # add your own instructions here + def init_parser @parser = Instruction_parser.new - # manga download + init_parser_mangas_related + init_parser_utilities + # params related + @parser.jump_when('id', 2) + @parser.jump_when('link', 1) + @parser.jump_when('file', 1) + @parser.jump_when('query', 1) + @parser.jump_when('set', 2) + @parser.jump_when('p', 1) + @parser.jump_when('c', 1) + @parser.jump_when('v', 1) + end + + def init_parser_utilities + @parser.on 'to-file' do |args| + buff = get_valid_data('to-file', false, args, false) # <================================= currently a placeholder + # todo to-file + puts 'placeholder for to-file' + pp buff + end + @parser.on 'macros' do |args| # <========================================================== currently a placeholder + # todo macros + puts 'placeholder for macros' + tmp = get_data_parser('macros') + tmp.parse args + end + @parser.on 'param', 'params' do |args| + params_management(args) if required_arguments('param', args) + end + @parser.on 'help', '--help', '-h' do || + help + end + @parser.on 'version', '--version' do || + version + end + @parser.on 'html' do |args| + buff = get_valid_data('html', false, args, false) + html_manager(buff) + end + @parser.on 'output' do |args| + buff = get_valid_data('output', false, args, false) + output(buff) unless buff.empty? + end + @parser.on 'details' do |args| + buff = get_valid_data('list', false, args, false) + details(buff) unless buff.empty? + end + end + + def init_parser_mangas_related + # adding @parser.on 'add' do |args| buff = get_valid_data('add', true, args) add(buff, true) unless buff.empty? end + @parser.on 'download', 'dl' do |args| + buff = get_valid_data('download', true, args, false) + download(buff) unless buff.empty? + end + # updating @parser.on 'update' do |args| buff = get_valid_data('update', false, args) update(buff) unless buff.empty? @@ -82,39 +155,33 @@ def init_parser buff = get_valid_data('update', false, args) update(buff, false, true) unless buff.empty? end - @parser.on 'download', 'dl' do |args| - buff = get_valid_data('download', true, args, false) - download(buff) unless buff.empty? - end + # data related @parser.on 'data-check' do |args| puts 'data-check is currently a placeholder' - buff = get_valid_data('data-check', true, args) # <========================================================== + buff = get_valid_data('data-check', true, args) # <===================================== currently a place holder # todo correct # fonction pour ajouter les nouveaux champs de données aux traces # permet aussi de supprimer les chapitres avec un mauvais nombre de pages # cette fonction vient étendre delete-diff end + # correcting @parser.on 'redl', 're-download' do |args| re_download(args, self) end - # html - @parser.on 'html' do |args| - buff = get_valid_data('html', false, args, false) - html_manager(buff) + @parser.on 'data' do |args| + buff = get_valid_data('data', false, args) + data(buff) unless buff.empty? end - # manga database related + # _todo @parser.on 'clear' do |args| buff = get_valid_data('clear', false, args) clear(buff) unless buff.empty? end - @parser.on 'data' do |args| - buff = get_valid_data('data', false, args) - data(buff) unless buff.empty? - end @parser.on 'todo' do |args| buff = get_valid_data('update', false, args) update(buff, true) unless buff.empty? end + # delete @parser.on 'delete' do |args| buff = get_valid_data('delete', false, args) delete(buff) unless buff.empty? @@ -123,54 +190,15 @@ def init_parser buff = get_valid_data('delete-db', false, args) delete(buff, false) unless buff.empty? end - @parser.on 'output' do |args| - buff = get_valid_data('output', false, args, false) - output(buff) unless buff.empty? - end - @parser.on 'to-file' do |args| - buff = get_valid_data('to-file', false, args, false) # <===================================================== - # todo to-file - puts 'placeholder for to-file' - pp buff - end - @parser.on 'details' do |args| - buff = get_valid_data('list', false, args, false) - details(buff) unless buff.empty? - end - # params related - @parser.on 'macros' do |args| # <============================================================================== - # todo macros - puts 'placeholder for macros' - tmp = get_data_parser('macros') - tmp.parse args - end - @parser.on 'param', 'params' do |args| - params_management(args) if required_arguments('param', args) - end - # other - # help and version completely ignore the arguments that are given to them - @parser.on 'help', '--help', '-h' do || - help - end - @parser.on 'version', '--version' do || - version - end - @parser.jump_when('id', 2) - @parser.jump_when('link', 1) - @parser.jump_when('file', 1) - @parser.jump_when('query', 1) - @parser.jump_when('set', 2) - @parser.jump_when('p', 1) - @parser.jump_when('c', 1) - @parser.jump_when('v', 1) end public + # clears the validated Manga_Data array to allow re-usage of the class def clear_data @data_to_prepare.clear end - # executes the program + # executes the instructions def run if ARGV.size == 0 puts 'no arguments, executing default' diff --git a/sources/Classes/instructions/Manga_data_filter.rb b/sources/instructions/Manga_data_filter.rb similarity index 100% rename from sources/Classes/instructions/Manga_data_filter.rb rename to sources/instructions/Manga_data_filter.rb diff --git a/sources/Classes/instructions/Parsers/Data_parser.rb b/sources/instructions/Parsers/Data_parser.rb similarity index 100% rename from sources/Classes/instructions/Parsers/Data_parser.rb rename to sources/instructions/Parsers/Data_parser.rb diff --git a/sources/Classes/instructions/Parsers/File_parser.rb b/sources/instructions/Parsers/File_parser.rb similarity index 100% rename from sources/Classes/instructions/Parsers/File_parser.rb rename to sources/instructions/Parsers/File_parser.rb diff --git a/sources/Classes/instructions/Parsers/Instruction_parser.rb b/sources/instructions/Parsers/Instruction_parser.rb similarity index 88% rename from sources/Classes/instructions/Parsers/Instruction_parser.rb rename to sources/instructions/Parsers/Instruction_parser.rb index 403ffe9..3c66cd5 100644 --- a/sources/Classes/instructions/Parsers/Instruction_parser.rb +++ b/sources/instructions/Parsers/Instruction_parser.rb @@ -1,10 +1,19 @@ # this class is used to cut the arguments given to MangaScrap and allow class Instruction_parser private - # function used to exit whenever there is not enought argument for a 'jump' + # function used to exit whenever there is not enough argument for a 'jump' + # jump : number of arguments required + # prev : the argument + # parent : the instruction def jump_error_exit(prev, jump, parent) puts 'Error : '.red + prev.yellow + ' requires ' + jump.to_s.yellow + ' more argument(s)' puts 'in : [' + parent + ']' + case prev + when 'id' + puts 'id '.yellow + 'requires a ' + 'name'.blue + ' ( first argument ) and a ' + 'site'.blue + ' ( second argument )' +s else + # other instructions + end exit 4 end diff --git a/sources/Classes/instructions/Parsers/Query_Parser.rb b/sources/instructions/Parsers/Query_Parser.rb similarity index 100% rename from sources/Classes/instructions/Parsers/Query_Parser.rb rename to sources/instructions/Parsers/Query_Parser.rb diff --git a/sources/instructions/basic_instructions.rb b/sources/instructions/basic_instructions.rb deleted file mode 100644 index ddf1268..0000000 --- a/sources/instructions/basic_instructions.rb +++ /dev/null @@ -1,232 +0,0 @@ -# whenever a user confirmation is required, this function is called -def require_confirmation (message, manga_list = nil) - puts message - if manga_list != nil - output(manga_list) - puts '' - end - puts "Write 'YES' to continue" - ret = STDIN.gets.chomp - puts '' - if ret == 'YES' || ret == 'Yes' || ret == 'yes' - true - else - false - end -end - -# adds all mangas to the database -def add(mangas, generate_chapters = false) - puts 'adding ' + mangas.size.to_s + ' element(s) to database' - html = HTML.new - mangas.each do |manga| - dw = manga.get_download_class - if dw == nil - next - end - if generate_chapters - html.generate_chapter_index(manga, false) - end - end - html.generate_index - puts 'done' -end - -# updates all mangas by calling the right classes -# should todo_only = true, the function missing_chapters will be called instead of -# update ( witch also calls missing_chapters ) -# should fast_update be set to true, all elements with the Completed status will be -# ignored -def update(mangas, todo_only = false, fast_update = false) - html = HTML.new - params = Params.instance.get_params - if fast_update - mangas = mangas.reject{|manga| manga.data[8] == 'Completed'} - end - puts 'updating ' + mangas.size.to_s + ' element(s)' - mangas.each do |manga| - dw = manga.get_download_class - if dw == nil - next - end - if todo_only - generate_html = dw.todo - else - generate_html = dw.update - end - if params[6] == 'true' - generate_html = (delete_diff(dw.get_links, manga) || generate_html) - end - html.generate_chapter_index(manga) if generate_html - end - html.generate_index - html.generate_updated - puts 'done' -end - -# downloads the cover and description of every element -def data(mangas) - puts 'downloading data of ' + mangas.size.to_s + ' element(s)' - html = HTML.new - mangas.each do |manga| - dw = manga.get_download_class - if dw == nil - next - end - dw.data - html.generate_chapter_index(manga, false) - end - html.generate_index - puts 'done' -end - -# basically just adds all mangas before updating them all -# also re-filters the mangas to ensure that there are no errors -def download(mangas) - add(mangas) - puts '' - filter = Manga_data_filter.new(mangas) - mangas_prepared = filter.run(false, true) - update(mangas_prepared) -end - -# ensures that the HTML class is correctly used to generate all the needed html -def html_manager(mangas) - html = HTML.new - mangas.each do |manga| - html.generate_chapter_index(manga, true) - end - html.generate_index - html.generate_updated - puts 'done' -end - -# just displays the version of MangaScrap witch is contained in a file -def version - begin - file = File.new(__dir__ + '/../../utils/version.txt', 'r') - line = file.gets - file.close - rescue => err - puts 'Error : '.red + 'could not open version file' - puts err.message - err - end - puts 'MangaScrap version : ' + line -end - -# displays the name + site of the mangas ( used to create manga list files ) -def output(manga_list) - manga_list.sort{|a, b| a.link <=> b.link}.each do |manga| - puts manga.name + ' ' + manga.site - end -end - -# infos is used to get all the available information on the ùanga from the database -# this includes traces and _todo -def details(manga_list) - database = Manga_database.instance - manga_list.sort{|a, b| a.link <=> b.link}.each do |manga| - puts 'Details for : ' + manga.name.yellow - puts '' - puts 'Web :'.yellow - puts 'HTML name : ' + manga.data[11] - puts 'Site : ' + manga.site - puts 'Link : ' + manga.link - puts 'Database id : ' + manga.id.to_s - puts 'Author : ' + manga.data[5] - puts 'Artist : ' + manga.data[6] - puts 'Type : ' + manga.data[7] - puts 'Status : ' + manga.data[8] - puts 'Genres : ' + manga.data[9] - puts 'Year : ' + manga.data[10].to_s - puts 'Traces :'.yellow - puts 'downloaded chapters : ' - traces = database.get_trace(manga) - puts 'volumes : ' + traces.map{|e| e[2]}.uniq.size.to_s - puts 'chapters : ' + traces.size.to_s - pages = traces.map{|e| e[5]} - if pages.include? nil - puts 'Error : '.red + 'at least one chapter has no page count value in the database, please use the ' + 'data-check'.green + ' instruction to correct this' - else - puts 'pages : ' + pages.reduce(:+) - end - puts 'Todo :'.yellow - todo = database.get_todo(manga).size - # decouper les données en pages / chapitres - if todo == 0 - puts 'there are no todo to download' - else - # note : les todo s'accumulent ( la fonction de check ne semble pas fonctionner ) - puts "there is a total of #{todo} todo(s) to download" - end - end -end - -# delete all _todo elements from the manga list -def clear(manga_list) - if require_confirmation('you are about to ' + 'delete'.red + ' all todo elements of the following element(s) :', manga_list) - db = Manga_database.instance - manga_list.each do |manga| - db.clear_todo(manga) - end - puts 'deleted all todo elements' - else - puts 'did not delete anything' - end -end - -# deletes all the mangas of the list from the database -# should delete_files be set at true, the files will also be deleted -def delete(manga_list, delete_files = true) - if require_confirmation('you are about to ' + 'delete'.red + ' the following element(s) from the database' + ((delete_files) ? - ' and '.yellow + 'all of the downloaded pages' : - ' but ' + 'not'.yellow + ' the downloaded files' ), manga_list) - db = Manga_database.instance - path = Params.instance.get_params[1] - manga_list.each do |manga| - db.delete_manga(manga) - if delete_files - site_dir = get_dir_from_site(manga.site) - delete_files(path + site_dir + 'html/' + manga.name, '.html') - delete_files(path + site_dir + 'mangas/' + manga.name, '.jpg') - end - end - puts 'deleted all elements' - HTML.new.generate_index - else - puts 'did not delete anything' - end -end - -# displays the help after colorizing it -def help - begin - file = File.open('utils/help.txt', 'r') - content = file.read - content = content.gsub('_todo', 'todo') - instructions = %w(link id file query all add update fast-update download redl param version help list output delete delete-db details html todo clear todo reset set data) - instructions.each do |instruction| - content = content.gsub('[' + instruction + ']g', instruction.green).gsub('[' + instruction + ']y', instruction.yellow) - end - content = content.gsub('INSTRUCTIONS', 'INSTRUCTIONS'.red) - content = content.gsub('EXAMPLES', 'EXAMPLES'.red) - content = content.gsub('DESCRIPTION', 'DESCRIPTION'.red) - content = content.gsub('Warning !', 'Warning !'.red) - content = content.gsub('NOT', 'NOT'.red) - content = content.gsub('note :', 'note :'.magenta) - content = content.gsub('definition :', 'definition :'.magenta) - content = content.gsub('definitions :', 'definitions :'.magenta) - content = content.gsub('[data arguments compatible]', '[data arguments compatible]'.blue) - content = content.gsub('[own arguments]', '[own arguments]'.blue) - content = content.gsub('[in database]', '[in database]'.blue) - content = content.gsub('[not in database]', '[not in database]'.blue) - content = content.gsub('[elements required]', '[elements required]'.blue) - content = content.gsub('[data argument]', '[data argument]'.blue) - content = content.gsub('[data arguments]', '[data arguments]'.blue) - puts content - rescue Errno::ENOENT => e - puts 'could not open help file' - puts e.message - end -end diff --git a/sources/instructions/params.rb b/sources/instructions/params.rb index ad32601..bb88ca2 100644 --- a/sources/instructions/params.rb +++ b/sources/instructions/params.rb @@ -1,7 +1,7 @@ # reading the file, adding DB values and setting the colors ( when needed ) def param_list params = Params.instance.get_params - template = File.open('templates/params.txt').read + template = File.open('sources/templates/text/params.txt').read template = template.gsub('#{params[1]}', params[1].green) template = template.gsub('#{params[2]}', params[2].to_s.green.to_s) template = template.gsub('#{params[3]}', params[3].to_s.green.to_s) diff --git a/sources/Classes/instructions/query.rb b/sources/instructions/query.rb similarity index 100% rename from sources/Classes/instructions/query.rb rename to sources/instructions/query.rb diff --git a/utils/help.txt b/sources/templates/text/help.txt similarity index 100% rename from utils/help.txt rename to sources/templates/text/help.txt diff --git a/templates/params.txt b/sources/templates/text/params.txt similarity index 100% rename from templates/params.txt rename to sources/templates/text/params.txt diff --git a/sources/templates/text/version.txt b/sources/templates/text/version.txt new file mode 100644 index 0000000..35ad344 --- /dev/null +++ b/sources/templates/text/version.txt @@ -0,0 +1 @@ +0.11.4 diff --git a/templates/chapter_index_template.css b/sources/templates/web/chapter_index_template.css similarity index 100% rename from templates/chapter_index_template.css rename to sources/templates/web/chapter_index_template.css diff --git a/templates/chapter_index_template.html b/sources/templates/web/chapter_index_template.html similarity index 100% rename from templates/chapter_index_template.html rename to sources/templates/web/chapter_index_template.html diff --git a/templates/chapter_index_template.js b/sources/templates/web/chapter_index_template.js similarity index 100% rename from templates/chapter_index_template.js rename to sources/templates/web/chapter_index_template.js diff --git a/templates/chapter_template.css b/sources/templates/web/chapter_template.css similarity index 100% rename from templates/chapter_template.css rename to sources/templates/web/chapter_template.css diff --git a/templates/chapter_template.html b/sources/templates/web/chapter_template.html similarity index 100% rename from templates/chapter_template.html rename to sources/templates/web/chapter_template.html diff --git a/templates/chapter_template.js b/sources/templates/web/chapter_template.js similarity index 100% rename from templates/chapter_template.js rename to sources/templates/web/chapter_template.js diff --git a/templates/manga_index_template.css b/sources/templates/web/manga_index_template.css similarity index 100% rename from templates/manga_index_template.css rename to sources/templates/web/manga_index_template.css diff --git a/templates/manga_index_template.html b/sources/templates/web/manga_index_template.html similarity index 100% rename from templates/manga_index_template.html rename to sources/templates/web/manga_index_template.html diff --git a/templates/manga_index_template.js b/sources/templates/web/manga_index_template.js similarity index 100% rename from templates/manga_index_template.js rename to sources/templates/web/manga_index_template.js diff --git a/templates/manga_updated_index_template.css b/sources/templates/web/manga_updated_index_template.css similarity index 100% rename from templates/manga_updated_index_template.css rename to sources/templates/web/manga_updated_index_template.css diff --git a/templates/manga_updated_index_template.html b/sources/templates/web/manga_updated_index_template.html similarity index 100% rename from templates/manga_updated_index_template.html rename to sources/templates/web/manga_updated_index_template.html diff --git a/sources/utils/utils_manga.rb b/sources/utils/utils_manga.rb index 8eda4a2..9e676dc 100644 --- a/sources/utils/utils_manga.rb +++ b/sources/utils/utils_manga.rb @@ -111,6 +111,7 @@ def description_manipulation(description, line_size = 120, min_nb_lines = 0) ret end +# used to get the volume, chapter and page of a link as an array def data_extractor_MF(link) if link[link.size - 1] == '/' page = 1 diff --git a/utils/version.txt b/utils/version.txt deleted file mode 100644 index 1a96df1..0000000 --- a/utils/version.txt +++ /dev/null @@ -1 +0,0 @@ -0.11.3