~mro/Photos2Atom

4ee7aa40979837b3612974419076bb6b878bc03d — Marcus Rohrmoser 4 years ago 7c2553d de
- progressive jpegs
- validate xml
3 files changed, 32 insertions(+), 28 deletions(-)

M Makefile
M README.md
M atom.sh
M Makefile => Makefile +8 -5
@@ 12,15 12,15 @@ _build/200/%: src/%
	@-mkdir -p _build/200
	@# https://www.smashingmagazine.com/2015/06/efficient-image-resizing-with-imagemagick/
	@# https://www.linuxquestions.org/questions/linux-software-2/question-about-thumbnail-orientation-dimensions-with-imagemagick-493034/
	convert $< -thumbnail 200x200 -auto-orient -quality 30% -strip -define png:exclude-chunk=all $@
	convert $< -thumbnail 200x200  -quality 30% -auto-orient -strip -define png:exclude-chunk=all -interlace Plane $@
	@touch -r "$<" "$@"

_build/1200/%: src/%
	@-mkdir -p _build/1200
	convert $< -resize 1200x1200\> -auto-orient -quality 82% -strip -define png:exclude-chunk=all $@
	convert $< -resize 1200x1200\> -quality 82% -auto-orient -strip -define png:exclude-chunk=all -interlace Plane $@
	@touch -r "$<" "$@"

build: thumb large _build/index.xml
build: _build/index.xml

all: build



@@ 32,5 32,8 @@ SRC := $(wildcard src/*)
thumb: $(patsubst src/%,_build/200/%,${SRC})
large: $(patsubst src/%,_build/1200/%,${SRC})

_build/index.xml: ${SRC}
	sh ./atom.sh '$(title)' '$(base)' $^ > $@
_build/index.xml.raw: thumb large
	sh ./atom.sh '$(title)' '$(base)' ${SRC} > $@

_build/index.xml: rfc4287.rng _build/index.xml.raw
	xmllint --format --encode utf-8 --nocdata --nonet --output $@ --relaxng $^

M README.md => README.md +2 -1
@@ 8,14 8,15 @@ Prepare a static photo feed for publication on a webserver.

    $ # optional:
    $  sh ./install-lightbox2.sh
    $  rsync -aP assets _build/

    $ rsync -avPz _build/ example.org:/var/www/.../
    $ rsync -avPz assets/ example.org:/var/www/.../assets/

## Prerequisites

- [make](https://www.gnu.org/software/make/)
- [imagemagick](https://imagemagick.org/)
- [xmllint](http://xmlsoft.org/xmllint.html)
- [rsync](http://rsync.samba.org/)
- [curl](https://curl.haxx.se/)


M atom.sh => atom.sh +22 -22
@@ 62,16 62,16 @@ cat <<Endofmessage
	'application/xml' without charset specified.
-->
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:georss="http://www.georss.org/georss">
	<title>${title}</title>
	<generator uri="http://purl.mro.name/Photos2Atom">Photos2Atom</generator>
	<id>${base}/</id>
	<updated>$(file_date_iso8601 "${youngest}")</updated>
	<link href="${base}/" rel="self" type="application/atom+xml"/>
	<link href="${base}/" rel="alternate" type="text/html"/>
	<author>
		<name>John Doe</name>
		<uri>http://example.com/~jd</uri>
	</author>
 <title><![CDATA[${title}]]></title>
 <generator uri="http://purl.mro.name/Photos2Atom">Photos2Atom</generator>
 <id>${base}/</id>
 <updated>$(file_date_iso8601 "${youngest}")</updated>
 <link href="${base}/" rel="self" type="application/atom+xml"/>
 <link href="${base}/" rel="alternate" type="text/html"/>
 <author>
  <name>John Doe</name>
  <uri>http://example.com/~jd</uri>
 </author>
Endofmessage

while [ "" != "${1}" ]


@@ 82,18 82,18 @@ do
	size="$(file_size "_build/200/${file}"y%)"

	cat <<Endofmessage
	<entry>
		<id>${base}/#${file}</id>
		<updated>$(file_date_iso8601 "${src}")</updated>
		<title></title>
		<summary/>
		<content src="${base}/1200/${file}" type="${mime}"/>
		<media:thumbnail url="${base}/200/${file}"/>
		<!-- georss:point>47.874091670000006 12.639475000000001</georss:point -->
		<link href="${base}/200/${file}" rel="previewimage" length="${size}" type="${mime}"/>
		<link href="${base}/1200/${file}" rel="enclosure" length="$(file_size "_build/1200/${file}")" type="${mime}"/>
		<link href="${base}/1200/${file}" type="${mime}"/>
	</entry>
 <entry>
  <id>${base}/#${file}</id>
  <updated>$(file_date_iso8601 "${src}")</updated>
  <title></title>
  <summary/>
  <content src="${base}/1200/${file}" type="${mime}"/>
  <media:thumbnail url="${base}/200/${file}"/>
  <!-- georss:point>47.874091670000006 12.639475000000001</georss:point -->
  <link href="${base}/200/${file}" rel="previewimage" length="${size}" type="${mime}"/>
  <link href="${base}/1200/${file}" rel="enclosure" length="$(file_size "_build/1200/${file}")" type="${mime}"/>
  <link href="${base}/1200/${file}" type="${mime}"/>
 </entry>
Endofmessage
  shift
done