Pensieve header: Development makefile for Agenda, Confessions, and Monoblog.

SetDirectory["C:\\drorbn\\AcademicPensieve\\Projects\\Agenda"]

Print["Projects/Agenda: Making Monoblog.png and Monoblog.html..."];
$MonoblogPages=Import["Monoblog.pdf", "PageCount"];
rows=First@Ordering[Table[
Abs[Log[(9/16)((8.5Ceiling[$MonoblogPages/rows])/(11rows))]],
{rows, $MonoblogPages}
]];
cols=Ceiling[$MonoblogPages/rows];
DeleteFile[FileNames["scratch/M-*.png"]];
Read["!convert -scene 1 -density "<>ToString[dpi]<>" -background white -alpha remove Monoblog.pdf scratch/M.png"];
Read["!montage -geometry +0+0 -frame 0 -background white -tile "<>ToString[cols]<>"x"<>ToString[rows]<>" scratch/M-*.png Monoblog.png"];
DeleteFile[FileNames["scratch/M-*.png"]];
If[FileType["thumbs"] === None, CreateDirectory["thumbs"]];
Export["thumbs/Monoblog.png",ImageResize[Import["Monoblog.png"], {200}]];
es1 = Get["Monoblog.pos"]//Most;
es2 = es1 /. Entry[k_, id_, x_,y_] :> If[x<4.25,
Entry[2k-1, id, x, 11-y],
Entry[2k, id, x-4.25, 11-y]
];
es3 = Flatten[Table[
If[es2[[k,1]]≠es2[[k+1,1]] && es2[[k+1,4]] >0.42,
{
Entry[es2[[k,1]], es2[[k,2]]<>"-1", {0, es2[[k,4]]-0.1},{4.25,11}],
Entry[es2[[k,1]]+1, es2[[k,2]]<>"-2", {0, 0},{4.25,es2[[k+1,4]]+0.1}]
},
Entry[es2[[k,1]], es2[[k,2]], {0, es2[[k,4]]-0.1}, {4.25,If[es2[[k+1,4]]>es2[[k,4]], es2[[k+1,4]]+0.1, 11]}]
],
{k, Length[es2]-1}
]];
es4 = es3 /. Entry[k_, id_, {x1_,y1_}, {x2_,y2_}] :> Module[{sx,sy},
sx=4.25*Mod[k-1, 2cols]; sy=11*Quotient[k-1, 2cols];
Entry[id, {sx+x1,sy+y1}, {sx+x2,sy+y2}]
];
es5 = es4 /. Entry[id_, {x1_,y1_}, {x2_,y2_}] :> StringJoin["  [", ToString[x1], ",", ToString[y1], ",", ToString[x2], ",", ToString[y2], ",\"", id, "\"]"];
views=StringJoin@@Riffle[es5, ",\n"];
FileTemplateApply[FileTemplate["Monoblog.txt"], "Monoblog.html"]

es2[[30;;31]]

es2[[66;;67]]