Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.1.1 #174

Merged
merged 17 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ RUN VERSION=$(grep -A 1 'BUNDLED WITH' Gemfile.lock | tail -n 1 | xargs); \
RUN apt update && apt install -y python3 python3-pip

# install python packages
RUN python3 -m pip install --upgrade --requirement requirements.txt
RUN python3 -m pip install --no-cache-dir --upgrade --requirement requirements.txt

# install python package for listening for file changes
RUN pip install "watchdog[watchmedo]"
RUN pip install "watchdog[watchmedo]==3.0.0"
vincerubinetti marked this conversation as resolved.
Show resolved Hide resolved

# ports used by jekyll
EXPOSE 4000
Expand Down
13 changes: 8 additions & 5 deletions .docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ echo ""
ls
echo ""

# run jekyll serve in hot-reload mode.
# rerun whenever _config.yaml changes (jekyll hot-reload doesn't work with this file).
# run cite process
python3 _cite/cite.py

# run jekyll serve in hot-reload mode
# rerun whenever _config.yaml changes (jekyll hot-reload doesn't work with this file)
watchmedo auto-restart \
--debug-force-polling \
--patterns="_config.yaml" \
--signal SIGTERM \
-- bundle exec jekyll serve --open-url --force_polling --livereload --trace --host=0.0.0.0 \
| sed 's/0.0.0.0/localhost/g' &
| sed "s/LiveReload address.*//g;s/0.0.0.0/localhost/g" &

# run cite process.
# rerun whenever _data files change.
# rerun cite process whenever _data files change
watchmedo shell-command \
--debug-force-polling \
--recursive \
--wait \
--command="python3 _cite/cite.py" \
--patterns="_data/sources*;_data/orcid*;_data/pubmed*;_data/google-scholar*" \
4 changes: 4 additions & 0 deletions .github/user_pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This website is based on the Lab Website Template.
See its documentation for working with this site:

https://greene-lab.gitbook.io/lab-website-template-docs
vincerubinetti marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions .github/workflows/build-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
runs-on: ubuntu-latest

steps:
# for debugging
- name: Print contexts
uses: crazy-max/ghaction-dump-context@v1

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-site.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
runs-on: ubuntu-latest

steps:
# for debugging
- name: Print contexts
uses: crazy-max/ghaction-dump-context@v1

Expand Down
35 changes: 19 additions & 16 deletions .github/workflows/first-time-setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
runs-on: ubuntu-latest

steps:
# for debugging
- name: Print contexts
uses: crazy-max/ghaction-dump-context@v1

Expand All @@ -28,9 +29,11 @@ jobs:
with:
ref: gh-pages

# clean slate, as if starting from orphan branch
- name: Clear Pages branch
run: rm -rf * .github .gitignore
run: rm -rf * .*
vincerubinetti marked this conversation as resolved.
Show resolved Hide resolved

# prevent GitHub from running Jekyll a second time after build
- name: Make .nojekyll file
run: touch .nojekyll

Expand All @@ -46,15 +49,18 @@ jobs:
- name: Checkout main branch
uses: actions/checkout@v3

- name: Remove unneeded files
- name: Remove files user doesn't need
run: |
rm -rf \
README.md \
CHANGELOG.md \
testbed.md \
.github/ISSUE_TEMPLATE \
.github/workflows/versioning.yaml \
.github/pull_request_template.md \

- name: Rename files
run: \
mv .github/user_pull_request_template.md .github/pull_request_template.md

- name: Set vars for personalization
run: |
Expand All @@ -73,25 +79,22 @@ jobs:
_Built with [Lab Website Template](https://greene-lab.gitbook.io/lab-website-template-docs)_
" > README.md

- name: Install packages
run: yarn add yaml

- name: Personalize Jekyll config for user
uses: actions/github-script@v6
with:
script: |
const { readFileSync, writeFileSync } = require("fs");
const { parse, stringify } = require("yaml");
const file = "_config.yaml";
const config = parse(readFileSync(file).toString());
config.title = "${{ env.USER }}";
config.description = "${{ env.DESCRIPTION }}";
config.email = "contact@${{ env.USER }}.com";
config.github = "${{ env.USER }}";
config.twitter = "${{ env.USER }}";
config.instagram = "${{ env.USER }}";
config.youtube = "${{ env.USER }}";
writeFileSync(file, stringify(config));
const contents = readFileSync(file)
.toString()
.replace(/(^title: ).*$/m, "$1${{ env.USER }}")
.replace(/(^subtitle: ).*$/m, "$1")
.replace(/(^description: ).*$/m, "$1${{ env.DESCRIPTION }}")
.replace(/(^ email: ).*$/m, "$1contact@${{ env.USER }}.com")
.replace(/(^ github: ).*$/m, "$1${{ env.USER }}")
.replace(/(^ twitter: ).*$/m, "$1${{ env.USER }}")
.replace(/(^ youtube: ).*$/m, "$1${{ env.USER }}");
writeFileSync(file, contents);

- name: Personalize homepage for user
uses: actions/github-script@v6
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/update-citations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
timeout-minutes: 15

steps:
# for debugging
- name: Print contexts
uses: crazy-max/ghaction-dump-context@v1

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/update-url.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
runs-on: ubuntu-latest

steps:
# for debugging
- name: Print contexts
uses: crazy-max/ghaction-dump-context@v1

Expand All @@ -31,6 +32,7 @@ jobs:
- name: Checkout branch contents
uses: actions/checkout@v3

# update link to site in readme
- name: Update readme
uses: actions/github-script@v6
with:
Expand Down
34 changes: 21 additions & 13 deletions .github/workflows/versioning.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
# for debugging
- name: Print contexts
uses: crazy-max/ghaction-dump-context@v1

Expand Down Expand Up @@ -54,10 +55,10 @@ jobs:
);
const changelog = readFileSync("pr/CHANGELOG.md")
.toString()
.split(/^##?#?#?/m)
.split(/^## /m)
vincerubinetti marked this conversation as resolved.
Show resolved Hide resolved
.map((section) => {
const [heading, ...body] = section.split("\n");
return { heading, body: body.join("\n") };
return [heading.trim(), body.join("\n").trim()];
});

// check version
Expand All @@ -71,8 +72,8 @@ jobs:

// check changelog
const newSection = changelog.find(
({ heading, body }) =>
heading.includes(newVersion) && heading.includes(newDate) && body.trim()
([heading, body]) =>
heading.includes(newVersion) && heading.includes(newDate) && body
);
if (!newSection) throw Error("Changelog not updated or not valid");

Expand All @@ -83,6 +84,7 @@ jobs:
github.event_name == 'push'
runs-on: ubuntu-latest
steps:
# for debugging
- name: Print contexts
uses: crazy-max/ghaction-dump-context@v1

Expand All @@ -106,24 +108,30 @@ jobs:
);
const changelog = readFileSync("CHANGELOG.md")
.toString()
.split(/^##?#?#?/m)
.split(/^## /m)
.map((section) => {
const [heading, ...body] = section.split("\n");
return { heading, body: body.join("\n") };
return [heading.trim(), body.join("\n").trim()];
});

// find changelog body for version
const body =
const [, body = ""] =
changelog.find(
({ heading }) => heading.includes(version) && heading.includes(date)
)?.body || "";
([heading]) => heading.includes(version) && heading.includes(date)
) || [];

return { version, body };

- name: Create tag and GitHub release
- name: Create tag
id: tag
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ fromJson(steps.version.outputs.result).version }}

- name: Create GitHub release
uses: ncipollo/release-action@v1
with:
commit: ${{ github.ref }}
tag: v${{ fromJson(steps.version.outputs.result).version }}
name: v${{ fromJson(steps.version.outputs.result).version }}
tag: ${{ fromJson(steps.version.outputs.result).version }}
name: ${{ fromJson(steps.version.outputs.result).version }}
body: ${{ fromJson(steps.version.outputs.result).body }}
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

Reference: common-changelog.org

## 1.1.1 - 2023-04-06

### Changed

- Change member profile page from col layout to float.
- Fix first time setup. Preserve config formatting and comments.
- Improve Docker cite process behavior.
- Fix post excerpt component start/end markers and special search attr chars.
- Fix misc CSS.

### Added

- Add show-title and show-subtitle site config options.
- Include site subtitle in description meta tag.
- Add user pull request template.
- Add title and link fallbacks to citation component.

## 1.1.0 - 2023-03-17

Add alert component, Docker support, accessibility fixes.
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# citation metadata for the template itself

title: "Lab Website Template"
version: 1.1.0
date-released: 2023-03-17
version: 1.1.1
date-released: 2023-04-06
url: "https://github.com/greenelab/lab-website-template"
authors:
- family-names: "Rubinetti"
Expand Down
16 changes: 10 additions & 6 deletions _cite/cite.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
cite process to convert sources and metasources into full citations
"""

from importlib import import_module
from pathlib import Path
from dotenv import load_dotenv
Expand Down Expand Up @@ -85,11 +89,11 @@

# merge sources with matching (non-blank) ids
for a in range(0, len(sources)):
id = sources[a].get("id")
if not id:
_id = sources[a].get("id")
if not _id:
continue
for b in range(a + 1, len(sources)):
if sources[b].get("id") == id:
if sources[b].get("id") == _id:
sources[a].update(sources[b])
sources[b] = {}
sources = [entry for entry in sources if entry]
Expand All @@ -113,15 +117,15 @@
citation = {}

# source id
id = source.get("id", "").strip()
_id = source.get("id", "").strip()

# Manubot doesn't work without an id
if id:
if _id:
log("Using Manubot to generate citation", 1)

try:
# run Manubot and set citation
citation = cite_with_manubot(source)
citation = cite_with_manubot(_id)

except Exception as e:
# if manually-entered source, throw error on cite failure
Expand Down
17 changes: 8 additions & 9 deletions _cite/plugins/google-scholar.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@ def query():
for work in response:

# create source
source = {}

# format source fields
source["id"] = work.get("citation_id", "")
source["title"] = work.get("title", "")
source["authors"] = list(map(str.strip, work.get("authors", "").split(",")))
source["publisher"] = work.get("publication", "")
source["date"] = work.get("year", "") + "-01-01"
source["link"] = work.get("link", "")
source = {
"id": work.get("citation_id", ""),
"title": work.get("title", ""),
"authors": list(map(str.strip, work.get("authors", "").split(","))),
"publisher": work.get("publication", ""),
"date": work.get("year", "") + "-01-01",
"link": work.get("link", ""),
}

# copy fields from entry to source
source.update(entry)
Expand Down
17 changes: 9 additions & 8 deletions _cite/util.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
utility functions for cite process and plugins
"""

import subprocess
import json
import yaml
Expand Down Expand Up @@ -64,7 +68,7 @@ def list_of_dicts(data):
check if data is list of dicts
"""

return type(data) == list and all(type(entry) == dict for entry in data)
return isinstance(data, list) and all(isinstance(entry, dict) for entry in data)


def format_date(date):
Expand Down Expand Up @@ -144,17 +148,14 @@ def save_data(path, data):

@log_cache
@cache.memoize(name="manubot", expire=90 * (60 * 60 * 24))
def cite_with_manubot(source):
def cite_with_manubot(_id):
"""
generate citation data for source with Manubot
generate citation data for source id with Manubot
"""

# source id
id = source.get("id")

# run Manubot
try:
commands = ["manubot", "cite", id, "--log-level=WARNING"]
commands = ["manubot", "cite", _id, "--log-level=WARNING"]
output = subprocess.Popen(commands, stdout=subprocess.PIPE).communicate()
except Exception as e:
log(e, 3)
Expand All @@ -170,7 +171,7 @@ def cite_with_manubot(source):
citation = {}

# original id
citation["id"] = id
citation["id"] = _id

# title
citation["title"] = manubot.get("title", "")
Expand Down
Loading