Skip to content

Commit

Permalink
Merge pull request #6 from openscd/Download_Script
Browse files Browse the repository at this point in the history
Download script
  • Loading branch information
juancho0202 authored Feb 27, 2024
2 parents 2b710e9 + e954ac3 commit 949a596
Show file tree
Hide file tree
Showing 29 changed files with 3,126 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/jekyll.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-node@v4
- name: Install NPM dependencies
run: cd scripts && npm ci
- name: Run Download script
run: cd scripts && npm run download
- name: Setup Ruby
uses: ruby/setup-ruby@ee2113536afb7f793eed4ce60e8d3b26db912da4 # v1.127.0
with:
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ gem 'kramdown'
gem 'rouge'
gem 'jekyll-toc'
gem "webrick", "~> 1.8"
gem 'jekyll-optional-front-matter'
13 changes: 10 additions & 3 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ description: > # this means to ignore newlines until "baseurl:"
Write an awesome description for your new site here. You can edit this
line in _config.yml. It will appear in your document head meta (for
Google search results) and in your feed.xml site description.
baseurl: "/Documentation" # the subpath of your site, e.g. /blog
url: "https://openscd.github.io" # the base hostname & protocol for your site
#baseurl: "/Documentation" # the subpath of your site, e.g. /blog
#url: "https://openscd.github.io" # the base hostname & protocol for your site
collections_dir: collections

# Markdown settings
Expand All @@ -27,7 +27,7 @@ toc:
ordered_list: false
no_toc_section_class: no_toc_section
list_id: toc
list_class: section-nav
list_class: nav--toc
sublist_class: ''
item_class: toc-entry
item_prefix: toc-
Expand All @@ -37,6 +37,12 @@ defaults:
path: "assets/images"
values:
image: true
- scope:
path: ""
values:
layout: "default"
cover: "home"


# Sass settings
sass:
Expand All @@ -62,3 +68,4 @@ plugins:
- jekyll-feed
- jekyll-sitemap
- jekyll-toc
- jekyll-optional-front-matter
1 change: 0 additions & 1 deletion _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<base href="{{ site.url }}{{ site.baseurl }}" />
<title>{% if page.title %}{{ page.title | escape }}{% else %}{{ site.title | escape }}{% endif %}</title>
<meta name="description" content="{{ page.excerpt | default: site.description | strip_html | normalize_whitespace | truncate: 160 | escape }}">

Expand Down
4 changes: 2 additions & 2 deletions _includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ <h1 class="brand">
</a>
</li>
<li>
<a class="nav__item">
Sub Item 3
<a class="nav__item" href="{{ 'pages/glossary' | relative_url }}">
Glossary
</a>
</li>
</ul>
Expand Down
29 changes: 22 additions & 7 deletions _layouts/guide.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,39 @@
<html lang="{{ site.lang | default: page.lang | default: 'en' }}">

{% include head.html %}
<link rel="stylesheet" href="{{ "/assets/css/github-markdown.css" | relative_url }}">
<style>
.markdown-body {
box-sizing: border-box;
min-width: 200px;
max-width: 980px;
margin: 45px auto;
padding: 45px;
}

@media (max-width: 767px) {
.markdown-body {
padding: 15px;
}
}
</style>
<body>
{% include header.html %}
<section class="content">
<section class="content content--sidebar">
<main class="main" aria-label="Content">
<div class="card">
<div class="card__header">
{{ page.name }}
</div>
<div class="card__content card__content--left">
{{ page.content }}
{{ page.summary }}
</div>
<div class="card">
<div class="card__content card__content--left markdown-body">
{{ page.content | inject_anchors }}
</div>
</div>
</main>
<aside>
<div class="card">
<div class="card__content">
{{ content | toc_only }}
{{ page.content | toc_only }}
</div>
</div>
</aside>
Expand Down
55 changes: 55 additions & 0 deletions _plugins/reading_time_filter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
module ReadingTimeFilter
include Liquid::StandardFilters

def reading_time(input)
# Get words count.
total_words = get_plain_text(input).split.size

# Load configuration.
config = @context.registers[:site].config["reading_time"]

# Setup default value.
if ! config
second_plural = "seconds"
minute_singular = "minute"
minute_plural = "minutes"
else
second_plural = config["second_plural"] ? config["second_plural"] : "seconds"
minute_singular = config["minute_singular"] ? config["minute_singular"] : "minute"
minute_plural = config["minute_plural"] ? config["minute_plural"] : "minutes"
end

# Average reading words per minute.
words_per_minute = 180

# Calculate reading time.
case total_words
when 0 .. 89
return "30 #{second_plural}"
when 90 .. 269
return "1 #{minute_singular}"
when 270 .. 449
return "2 #{minute_plural}"
when 450 .. 629
return "3 #{minute_plural}"
when 630 .. 809
return "4 #{minute_plural}"
when 810 .. 990
return "5 #{minute_plural}"
else
minutes = ( total_words / words_per_minute ).floor
return "#{minutes} #{minute_plural}";
end
end

def get_plain_text(input)
strip_html(strip_pre_tags(input))
end

def strip_pre_tags(input)
empty = ''.freeze
input.to_s.gsub(/<pre(?:(?!<\/pre).|\s)*<\/pre>/mi, empty)
end
end

Liquid::Template.register_filter(ReadingTimeFilter)
Loading

0 comments on commit 949a596

Please sign in to comment.