mirror of
https://github.com/hahwul/WebHackersWeapons.git
synced 2024-12-18 12:14:22 -05:00
Improve script
This commit is contained in:
parent
420b28a198
commit
9a7d691d4d
@ -34,6 +34,22 @@ def generate_tags array
|
|||||||
return tags
|
return tags
|
||||||
end
|
end
|
||||||
|
|
||||||
|
categorize_template_tags = %q{
|
||||||
|
## Tools for <%= @ct_tag %>
|
||||||
|
|
||||||
|
<%= @ct_head %>
|
||||||
|
<%= @ct_data %>
|
||||||
|
|
||||||
|
}.gsub(/^ /, '')
|
||||||
|
|
||||||
|
categorize_template_langs = %q{
|
||||||
|
## The <%= @ct_lang %> based tools
|
||||||
|
|
||||||
|
<%= @ct_head %>
|
||||||
|
<%= @ct_data %>
|
||||||
|
|
||||||
|
}.gsub(/^ /, '')
|
||||||
|
|
||||||
template = %q{
|
template = %q{
|
||||||
<h1 align="center">
|
<h1 align="center">
|
||||||
<br>
|
<br>
|
||||||
@ -88,6 +104,8 @@ WHW's open-source project and made it with ❤️ if you want contribute this pr
|
|||||||
|
|
||||||
tags = []
|
tags = []
|
||||||
langs = []
|
langs = []
|
||||||
|
categorize_tags = {}
|
||||||
|
categorize_langs = {}
|
||||||
head = "| Type | Name | Description | Star | Tags | Badges |\n"
|
head = "| Type | Name | Description | Star | Tags | Badges |\n"
|
||||||
head = head + "| --- | --- | --- | --- | --- | --- |"
|
head = head + "| --- | --- | --- | --- | --- | --- |"
|
||||||
tools = head + "\n"
|
tools = head + "\n"
|
||||||
@ -111,8 +129,14 @@ Dir.entries("./weapons/").each do | name |
|
|||||||
if name != '.' && name != '..'
|
if name != '.' && name != '..'
|
||||||
begin
|
begin
|
||||||
data = YAML.load(File.open("./weapons/#{name}"))
|
data = YAML.load(File.open("./weapons/#{name}"))
|
||||||
|
|
||||||
if data['type'] != "" && data['type'] != nil
|
if data['type'] != "" && data['type'] != nil
|
||||||
|
if weapons_obj[data['type'].downcase] != nil
|
||||||
weapons_obj[data['type'].downcase].push data
|
weapons_obj[data['type'].downcase].push data
|
||||||
|
else
|
||||||
|
weapons_obj[data['type'].downcase] = []
|
||||||
|
weapons_obj[data['type'].downcase].push data
|
||||||
|
end
|
||||||
else
|
else
|
||||||
weapons_obj['etc'].push data
|
weapons_obj['etc'].push data
|
||||||
end
|
end
|
||||||
@ -121,6 +145,7 @@ Dir.entries("./weapons/").each do | name |
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
weapons_obj.each do |key,value|
|
weapons_obj.each do |key,value|
|
||||||
weapons.concat value
|
weapons.concat value
|
||||||
end
|
end
|
||||||
@ -169,6 +194,28 @@ weapons.each do | data |
|
|||||||
else
|
else
|
||||||
puts name
|
puts name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
tmp_lang = data['lang']
|
||||||
|
tmp_tags = data['tags']
|
||||||
|
|
||||||
|
if tmp_tags != nil
|
||||||
|
tmp_tags.each do |t|
|
||||||
|
if categorize_tags[t] == nil
|
||||||
|
categorize_tags[t] = line + "\n"
|
||||||
|
else
|
||||||
|
categorize_tags[t] = categorize_tags[t] + line + "\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if tmp_lang != nil
|
||||||
|
if categorize_langs[tmp_lang] == nil
|
||||||
|
categorize_langs[tmp_lang] = line + "\n"
|
||||||
|
else
|
||||||
|
categorize_langs[tmp_lang] = categorize_langs[tmp_lang] + line + "\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
rescue => e
|
rescue => e
|
||||||
puts e
|
puts e
|
||||||
end
|
end
|
||||||
@ -177,3 +224,23 @@ end
|
|||||||
markdown = ERB.new(template, trim_mode: "%<>")
|
markdown = ERB.new(template, trim_mode: "%<>")
|
||||||
#puts markdown.result
|
#puts markdown.result
|
||||||
File.write './README.md', markdown.result
|
File.write './README.md', markdown.result
|
||||||
|
|
||||||
|
categorize_tags.each do |key,value|
|
||||||
|
if key != nil && key != ""
|
||||||
|
@ct_tag = key
|
||||||
|
@ct_head = head + "\n"
|
||||||
|
@ct_data = value
|
||||||
|
tag_markdown = ERB.new(categorize_template_tags, trim_mode: "%<>")
|
||||||
|
File.write "./categorize/tags/#{@ct_tag}.md", tag_markdown.result
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
categorize_langs.each do |key,value|
|
||||||
|
if key != nil && key != ""
|
||||||
|
@ct_lang = key
|
||||||
|
@ct_head = head + "\n"
|
||||||
|
@ct_data = value
|
||||||
|
lang_markdown = ERB.new(categorize_template_langs, trim_mode: "%<>")
|
||||||
|
File.write "./categorize/langs/#{@ct_lang}.md", lang_markdown.result
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user