<commit_before>SHELL = /bin/bash
DESTDIR = _site
PANDOC = pandoc

MEDIA_TYPES = png jpg jpeg gif pdf

# ==============================================================================
# Run `pandoc` from `content/**/README.org to `_site/**/index.html`
# ==============================================================================
CONTENT_SRC = content/%/README.org
CONTENT_DST = $(DESTDIR)/%/index.html
CONTENT_SRC_FILES = $(shell find 'content' -type f -name 'README.org')
CONTENT_DST_FILES = \
	$(patsubst $(CONTENT_SRC),$(CONTENT_DST),$(CONTENT_SRC_FILES))

$(CONTENT_DST): export YEONGHOEY_FILTER_BASE = https://media.yeonghoey.com
$(CONTENT_DST): export YEONGHOEY_FILTER_SRC = $<
$(CONTENT_DST): $(CONTENT_SRC)
	mkdir -p "$(dir $@)"
	pipenv run $(PANDOC) \
  --standalone \
  --mathjax \
  --css '/pandoc.css' \
  --filter 'scripts/filter.py' \
  --output '$@' \
  '$<'


# ==============================================================================
# Copy `static/**` to `$(DESTDIR)/`
# ==============================================================================
STATIC_SRC = static/%
STATIC_DST = $(DESTDIR)/%
STATIC_SRC_FILES = $(shell find static -type f)
STATIC_DST_FILES = \
	$(patsubst $(STATIC_SRC),$(STATIC_DST),$(STATIC_SRC_FILES))

$(STATIC_DST): $(STATIC_SRC)
	mkdir -p "$(dir $@)"
	cp '$<' '$@'


# ==============================================================================
# PHONY targets
# ==============================================================================
.PHONY: init ci update dev sync build clean

init:
	pipenv install --dev

ci:
	pipenv install

update:
	git pull --rebase --autostash

dev: sync build
	pipenv run python scripts/dev.py

build: $(CONTENT_DST_FILES) $(STATIC_DST_FILES)

sync:
	pipenv run aws s3 sync \
  's3://yeonghoey-media' \
  'content'
	pipenv run aws s3 sync \
  'content' \
  's3://yeonghoey-media' \
  --exclude '*' \
  $(patsubst %,--include '*.%',$(MEDIA_TYPES))

clean:
	-rm -rf $(DESTDIR)/*<commit_msg>Refactor sync and add prune to Makefile<commit_after>SHELL = /bin/bash
DESTDIR = _site
PANDOC = pandoc

MEDIA_TYPES = png jpg jpeg gif pdf

# ==============================================================================
# Run `pandoc` from `content/**/README.org to `_site/**/index.html`
# ==============================================================================
CONTENT_SRC = content/%/README.org
CONTENT_DST = $(DESTDIR)/%/index.html
CONTENT_SRC_FILES = $(shell find 'content' -type f -name 'README.org')
CONTENT_DST_FILES = \
	$(patsubst $(CONTENT_SRC),$(CONTENT_DST),$(CONTENT_SRC_FILES))

$(CONTENT_DST): export YEONGHOEY_FILTER_BASE = https://media.yeonghoey.com
$(CONTENT_DST): export YEONGHOEY_FILTER_SRC = $<
$(CONTENT_DST): $(CONTENT_SRC)
	mkdir -p "$(dir $@)"
	pipenv run $(PANDOC) \
  --standalone \
  --mathjax \
  --css '/pandoc.css' \
  --filter 'scripts/filter.py' \
  --output '$@' \
  '$<'


# ==============================================================================
# Copy `static/**` to `$(DESTDIR)/`
# ==============================================================================
STATIC_SRC = static/%
STATIC_DST = $(DESTDIR)/%
STATIC_SRC_FILES = $(shell find static -type f)
STATIC_DST_FILES = \
	$(patsubst $(STATIC_SRC),$(STATIC_DST),$(STATIC_SRC_FILES))

$(STATIC_DST): $(STATIC_SRC)
	mkdir -p "$(dir $@)"
	cp '$<' '$@'


# ==============================================================================
# PHONY targets
# ==============================================================================
.PHONY: init ci update dev sync sync-down sync-up prune build clean

init:
	pipenv install --dev

ci:
	pipenv install

update:
	git pull --rebase --autostash

dev: sync build
	pipenv run python scripts/dev.py

build: $(CONTENT_DST_FILES) $(STATIC_DST_FILES)

sync: sync-down sync-up

sync-down:
	pipenv run aws s3 sync \
  's3://yeonghoey-media' \
  'content'

sync-up:
	pipenv run aws s3 sync \
  'content' \
  's3://yeonghoey-media' \
  --exclude '*' \
  $(patsubst %,--include '*.%',$(MEDIA_TYPES)) \
  $(YEONGHOEY_SYNCFLAGS)

prune: YEONGHOEY_SYNCFLAGS = --delete --dryrun
prune: sync-up

clean:
	-rm -rf $(DESTDIR)/*
{'fraction_non_alphanumeric': 0.3647342995169082, 'fraction_numerical': 0.001932367149758454, 'mean_word_length': 5.199101796407185, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '577797', 'n_tokens_mistral': 1488, 'n_tokens_neox': 1358, 'n_words': 285}