Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
initial RSE4NFDI site
Browse files Browse the repository at this point in the history
  • Loading branch information
knarrff committed Apr 28, 2019
1 parent 29aa674 commit 295a925
Show file tree
Hide file tree
Showing 58 changed files with 25,265 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/_site/**
13 changes: 13 additions & 0 deletions 404.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
layout: default
permalink: /404.html
title: "404 - page not found"
---

# 404

**Page not found! :(**

Go to [German](/de/) or [English](/en/) page to try again.

Please [add an issue](https://github.com/DE-RSE/www/issues) if you think this should be fixed. Thanks!
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# www.de-rse.org hosting repository

This repository contains the source files for the RSE4NFDI website. Its official hosting URL is <https://www.rse4nfdi.de>.

The site is made to be built with [Jekyll](https://jekyllrb.com/) >= 3.4.1.

To build, run `bundle install` once and then `jekyll build`.
To preview locally, run `jekyll serve` and browse to <http://localhost:4000>.
To include drafts in the preview add the `--drafts` flag.

## Contributions

To contribute, please fork, change, test locally (see above) and create a pull request against `gh-pages`.

You can use [rake](http://rake.rubyforge.org/) to comfortably create content.

## Create content with `rake`

To create content, run one of the following commands from the repository root. `Rakefile` has been created by [Ellen Gummesson](http://ellengummesson.com/) and is hosted at <https://github.com/gummesson/jekyll-rake-boilerplate>.

`rake post["Title"]` creates a new blog post in `_posts`.

`rake draft["Title"]` creates a new blog post draft in `_drafts`

`rake publish` publishes blog post drafts from `_drafts` to `_posts` (interactive CLI-based picking of drafts to publish).

`rake page["Title"]` creates a new page (in the root folder).

`rake page["Title","Path/to/folder"]` creates a new page in the respective folder. E.g., to add a page to the English version of the site, use `rake["Title","en"]`.

## YAML headers for pages and posts

The repository contains minimal templates for pages and posts, `_page.txt` and `_post.txt`.

These are used when creating content with `rake` and include the minimal YAML headers needed for the content to show properly.

### Pages

---
title:
layout: default
weight:
---

Pages always have the `default` layout. They must also have a (short) `title` (in double quotes preferably, so it doesn't mess with the YAML), which will be used for the main menu as item texts. `weight` determines the position of the respective menu item in the menu (ascending order).

### Posts

---
title:
layout: post
author:
menulang: en
---

Blog posts will be displayed ordered by publication date on `blog.html`. They always have a `post` layout and must have a `title` and an `author`, both of which will be displayed on the blog index and the post page itself. Publication date is automatically added via `rake publish`. Do not start blog posts with headers (`#`), as the title will be displayed as header.

`menulang` determines the language of the main menu as displayed on the post page (default: `en`). The language menu items ("Deutsch", "English") link back to the blog index page in the respective language.

## kramdown

For help on syntax have a look at:

- [quick reference](https://kramdown.gettalong.org/quickref.html)
- or [syntax](https://kramdown.gettalong.org/quickref.html)

227 changes: 227 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
# == Dependencies ==============================================================

require 'rake'
require 'yaml'
require 'fileutils'
require 'rbconfig'

# == Configuration =============================================================

# Set "rake watch" as default task
task :default => :watch

# Load the configuration file
CONFIG = YAML.load_file("_config.yml")

# Get and parse the date
DATE = Time.now.strftime("%Y-%m-%d")
TIME = Time.now.strftime("%H:%M:%S")
POST_TIME = DATE + ' ' + TIME

# Directories
POSTS = "_posts"
DRAFTS = "_drafts"

# == Helpers ===================================================================

# Execute a system command
def execute(command)
system "#{command}"
end

# Chech the title
def check_title(title)
if title.nil? or title.empty?
raise "Please add a title to your file."
end
end

# Transform the filename and date to a slug
def transform_to_slug(title, extension)
characters = /("|'|!|\?|:|\s\z)/
whitespace = /\s/
"#{title.gsub(characters,"").gsub(whitespace,"-").downcase}.#{extension}"
end

# Read the template file
def read_file(template)
File.read(template)
end

# Save the file with the title in the YAML front matter
def write_file(content, title, directory, filename)
parsed_content = "#{content.sub("title:", "title: \"#{title}\"")}"
parsed_content = "#{parsed_content.sub("date:", "date: #{POST_TIME}")}"
File.write("#{directory}/#{filename}", parsed_content)
puts "#{filename} was created in '#{directory}'."
end

# Create the file with the slug and open the default editor
def create_file(directory, filename, content, title, editor)
FileUtils.mkdir(directory) unless File.exists?(directory)
if File.exists?("#{directory}/#{filename}")
raise "The file already exists."
else
write_file(content, title, directory, filename)
if editor && !editor.nil?
sleep 1
execute("#{editor} #{directory}/#{filename}")
end
end
end

# Get the "open" command
def open_command
if RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
"start"
elsif RbConfig::CONFIG["host_os"] =~ /darwin/
"open"
else
"xdg-open"
end
end

# == Tasks =====================================================================

# rake post["Title"]
desc "Create a post in _posts"
task :post, :title do |t, args|
title = args[:title]
template = CONFIG["post"]["template"]
extension = CONFIG["post"]["extension"]
editor = CONFIG["editor"]
check_title(title)
filename = "#{DATE}-#{transform_to_slug(title, extension)}"
content = read_file(template)
create_file(POSTS, filename, content, title, editor)
end

# rake draft["Title"]
desc "Create a post in _drafts"
task :draft, :title do |t, args|
title = args[:title]
template = CONFIG["post"]["template"]
extension = CONFIG["post"]["extension"]
editor = CONFIG["editor"]
check_title(title)
filename = transform_to_slug(title, extension)
content = read_file(template)
create_file(DRAFTS, filename, content, title, editor)
end

# rake publish
desc "Move a post from _drafts to _posts"
task :publish do
extension = CONFIG["post"]["extension"]
files = Dir["#{DRAFTS}/*.#{extension}"]
files.each_with_index do |file, index|
puts "#{index + 1}: #{file}".sub("#{DRAFTS}/", "")
end
print "> "
number = $stdin.gets
if number =~ /\D/
filename = files[number.to_i - 1].sub("#{DRAFTS}/", "")
FileUtils.mv("#{DRAFTS}/#{filename}", "#{POSTS}/#{DATE}-#{filename}")
puts "#{filename} was moved to '#{POSTS}'."
else
puts "Please choose a draft by the assigned number."
end
end

# rake page["Title"]
# rake page["Title","Path/to/folder"]
desc "Create a page (optional filepath)"
task :page, :title, :path do |t, args|
title = args[:title]
template = CONFIG["page"]["template"]
extension = CONFIG["page"]["extension"]
editor = CONFIG["editor"]
directory = args[:path]
if directory.nil? or directory.empty?
directory = "./"
else
FileUtils.mkdir_p("#{directory}")
end
check_title(title)
filename = transform_to_slug(title, extension)
content = read_file(template)
create_file(directory, filename, content, title, editor)
end

# rake build
desc "Build the site"
task :build do
execute("jekyll build")
end

# rake watch
# rake watch[number]
# rake watch["drafts"]
desc "Serve and watch the site (with post limit or drafts)"
task :watch, :option do |t, args|
option = args[:option]
if option.nil? or option.empty?
execute("jekyll serve --watch")
else
if option == "drafts"
execute("jekyll serve --watch --drafts")
else
execute("jekyll serve --watch --limit_posts #{option}")
end
end
end

# rake preview
desc "Launch a preview of the site in the browser"
task :preview do
port = CONFIG["port"]
if port.nil? or port.empty?
port = 4000
end
Thread.new do
puts "Launching browser for preview..."
sleep 1
execute("#{open_command} http://localhost:#{port}/")
end
Rake::Task[:watch].invoke
end

# rake deploy["Commit message"]
desc "Deploy the site to a remote git repo"
task :deploy, :message do |t, args|
message = args[:message]
branch = CONFIG["git"]["branch"]
if message.nil? or message.empty?
raise "Please add a commit message."
end
if branch.nil? or branch.empty?
raise "Please add a branch."
else
Rake::Task[:build].invoke
execute("git add .")
execute("git commit -m \"#{message}\"")
execute("git push origin #{branch}")
end
end

# rake transfer
desc "Transfer the site (remote server or a local git repo)"
task :transfer do
command = CONFIG["transfer"]["command"]
source = CONFIG["transfer"]["source"]
destination = CONFIG["transfer"]["destination"]
settings = CONFIG["transfer"]["settings"]
if command.nil? or command.empty?
raise "Please choose a file transfer command."
elsif command == "robocopy"
Rake::Task[:build].invoke
execute("robocopy #{source} #{destination} #{settings}")
puts "Your site was transfered."
elsif command == "rsync"
Rake::Task[:build].invoke
execute("rsync #{settings} #{source} #{destination}")
puts "Your site was transfered."
else
raise "#{command} isn't a valid file transfer command."
end
end
3 changes: 3 additions & 0 deletions _includes/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="footer">
<a href="{{ "./imprint.html" }}">Impressum (legal notice)</a>
</div>
36 changes: 36 additions & 0 deletions _includes/head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<head>
<meta charset="utf-8">
<script type="text/javascript" src="{{ "/js/header.js" | prepend: site.baseurl }}"></script>

{% if page.title != nil %}
{% assign page-title = page.title | prepend: " - " | escape %}
{% endif %}

<title>de-RSE.org {{ page-title }}</title>

<script type="text/javascript" src="{{ "/js/jquery-1.11.3.min.js" | prepend: site.baseurl }}"></script>
<script type="text/javascript" src="{{ "/bootstrap/js/bootstrap.min.js" | prepend: site.baseurl }}"></script>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" type="text/css" href="{{ "/bootstrap/css/bootstrap.min.css" | prepend: site.baseurl }}">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src='https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js'></script>
<script src='https://oss.maxcdn.com/respond/1.4.2/respond.min.js'></script>
<![endif]-->
<style>body { padding-top: 70px; }</style>
<link rel="stylesheet" type="text/css" href="{{ "/css/leaflet.css" | prepend: site.baseurl }}">
<link rel="stylesheet" type="text/css" href="{{ "/css/MarkerCluster.Default.css" | prepend: site.baseurl }}">
<link rel="stylesheet" type="text/css" href="{{ "/css/MarkerCluster.css" | prepend: site.baseurl }}">
<link rel="stylesheet" type="text/css" href="{{ "/css/rse4nfdi.css" | prepend: site.baseurl }}">
<link rel="icon" href="{{ "/assets/img/site/favicon.ico?" | prepend: site.baseurl }}" sizes="16x16 24x24 32x32 64x64" type="image/vnd.microsoft.icon">

<link rel="alternate" href="{{ "/de/index.html" | prepend: site.baseurl }}" hreflang="de"/>
<link rel="alternate" href="{{ "/en/index.html" | prepend: site.baseurl }}" hreflang="en"/>
<link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}" />

<meta name="description" content="">
<meta name="" content="">

<link rel="icon" href="{{ "/assets/img/site/favicon.ico" | prepend: site.baseurl }}">
<link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}">
</head>
Loading

0 comments on commit 295a925

Please sign in to comment.