Skip to content

Commit

Permalink
software.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
junsan1 committed Jul 6, 2024
1 parent 90e033d commit 531a832
Show file tree
Hide file tree
Showing 5 changed files with 511 additions and 14 deletions.
56 changes: 56 additions & 0 deletions _layouts/software_index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
layout: base
---
<h1>{{ page.title }}</h1>

<div id="filters">
{% assign all_filters = page.software | map: "filters" | flatten | uniq | sort %}
<button class="filter-btn active" data-filter="all">All</button>
{% for filter in all_filters %}
<button class="filter-btn" data-filter="{{ filter }}">{{ filter }}</button>
{% endfor %}
</div>

<div id="software-list">
{% for item in page.software %}
<div class="software-item" data-filters="{{ item.filters | join: ' ' }}">
<img src="{{ item.logo | relative_url }}" alt="{{ item.name }} logo">
<h2>{{ item.name }}</h2>
<p>{{ item.description }}</p>
<a href="{{ item.website }}" target="_blank" rel="noopener noreferrer">Official Website</a>
<a href="{{ item.pedia_link | relative_url }}">Learn More</a>
{% if item.github %}
<a href="{{ item.github }}" target="_blank" rel="noopener noreferrer">GitHub</a>
{% endif %}
<div class="filters">
{% for filter in item.filters %}
<span class="filter-tag">{{ filter }}</span>
{% endfor %}
</div>
</div>
{% endfor %}
</div>

<script>
document.addEventListener('DOMContentLoaded', function() {
const filterButtons = document.querySelectorAll('.filter-btn');
const softwareItems = document.querySelectorAll('.software-item');

filterButtons.forEach(button => {
button.addEventListener('click', function() {
const filter = this.dataset.filter;

filterButtons.forEach(btn => btn.classList.remove('active'));
this.classList.add('active');

softwareItems.forEach(item => {
if (filter === 'all' || item.dataset.filters.includes(filter)) {
item.style.display = 'block';
} else {
item.style.display = 'none';
}
});
});
});
});
</script>
53 changes: 52 additions & 1 deletion _plugins/letter_page_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,29 @@ def generate(site)
end

def process_section(site, lang, section, section_path)
if section == 'soft'
process_software_section(site, lang, section, section_path)
else
process_regular_section(site, lang, section, section_path)
end
end

def process_software_section(site, lang, section, section_path)
software_data = load_software_data(site, section_path)
site.pages << SoftwareIndexPage.new(site, site.source, lang, section, software_data)
end

def load_software_data(site, section_path)
yaml_file = File.join(section_path, 'software.yml')
if File.exist?(yaml_file)
YAML.load_file(yaml_file)
else
Jekyll.logger.warn "LetterPageGenerator:", "Software YAML file not found: #{yaml_file}"
[]
end
end

def process_regular_section(site, lang, section, section_path)
letters = Dir.entries(section_path)
.select { |entry| File.directory?(File.join(section_path, entry)) && entry != '.' && entry != '..' }
.map { |letter| [letter.downcase, count_posts(site, lang, section, letter)] }
Expand All @@ -38,7 +61,7 @@ def process_section(site, lang, section, section_path)
Jekyll.logger.info "LetterPageGenerator:", "Creating page for #{lang}/#{section}/#{letter} with #{count} posts"
site.pages << LetterPage.new(site, site.source, lang, section, letter)

Dir.glob(File.join(section_path, letter, '*.md')).each do |file|
Dir.glob(File.join(section_path, letter, '*.md')).each do |file|
Jekyll.logger.info "LetterPageGenerator:", "Processing file: #{file}"
process_markdown_file(site, file)
end
Expand Down Expand Up @@ -169,4 +192,32 @@ def section_name_zh(section)
end
end
end

class SoftwareIndexPage < Page
def initialize(site, base, lang, section, software_data)
@site = site
@base = base
@dir = File.join(lang, section)
@name = "index.md"

self.process(@name)
layout_file = File.join(base, '_layouts', 'software_index.html')
if File.exist?(layout_file)
self.read_yaml(File.dirname(layout_file), File.basename(layout_file))
else
Jekyll.logger.warn "LetterPageGenerator:", "Layout file 'software_index.html' not found"
self.data = {}
end
self.data['layout'] = 'software_index'
self.data['title'] = case lang
when 'en' then "Software Index"
when 'ru' then "Индекс программного обеспечения"
when 'zh' then "软件索引"
end
self.data['software'] = software_data
self.data['lang'] = lang
self.data['section'] = section
self.data['permalink'] = "/#{lang}/#{section}/index.html"
end
end
end
96 changes: 96 additions & 0 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,93 @@ footer a:hover .github-icon {
color: #666;
}

#filters {
text-align: center;
margin-bottom: 30px;
}

.filter-btn {
background-color: #007bff;
color: white;
border: none;
padding: 10px 20px;
margin: 5px;
cursor: pointer;
border-radius: 5px;
transition: background-color 0.3s;
}

.filter-btn:hover {
background-color: #0056b3;
}

.filter-btn.active {
background-color: #0056b3;
}

#software-list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 20px;
}

.software-item {
background-color: #f8f8f8;
border-radius: 10px;
padding: 20px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
transition: box-shadow 0.3s, transform 0.3s;
}

.software-item:hover {
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
transform: translateY(-5px);
}

.software-item img {
max-width: 100px;
height: auto;
display: block;
margin: 0 auto 15px;
}

.software-item h2 {
font-size: 1.2em;
color: #333;
margin-bottom: 10px;
text-align: center;
}

.software-item p {
font-size: 0.9em;
margin-bottom: 15px;
}

.software-item a {
display: inline-block;
margin-right: 10px;
color: #007bff;
text-decoration: none;
}

.software-item a:hover {
text-decoration: underline;
}

.filters {
margin-top: 15px;
}

.filter-tag {
display: inline-block;
background-color: #e9ecef;
color: #495057;
padding: 5px 10px;
margin: 2px;
font-size: 0.8em;
border-radius: 3px;
}

@media (max-width: 768px) {
.menu-toggle {
display: block;
Expand Down Expand Up @@ -261,4 +348,13 @@ footer a:hover .github-icon {
.letter-item .count {
font-size: 0.7em;
}

#software-list {
grid-template-columns: 1fr;
}

.filter-btn {
padding: 8px 15px;
font-size: 0.9em;
}
}
13 changes: 0 additions & 13 deletions en/soft/m/metatrader4.md

This file was deleted.

Loading

0 comments on commit 531a832

Please sign in to comment.