squeeze

A static site generator that can put the toothpaste back in the tube.
git clone https://git.mulligrubs.me/squeeze
Log | Files | Refs | README | LICENSE

gnu-prolog.pl (1392B)


      1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      2 % Predicate implementations for GNU-Prolog dialects.
      3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      4 
      5 % Detect GNU-Prolog
      6 gnu_prolog:-
      7 	catch(current_prolog_flag(dialect, gprolog), _, fail).
      8 
      9 gnu_prolog:-
     10 	catch(current_prolog_flag(prolog_name, 'GNU Prolog'), _, fail).
     11 
     12 
     13 % GNU-Prolog-specific predicate to run an external Markdown tool.
     14 % The command itself should be specified in your site.pl.
     15 markdown_to_html(MarkdownEntryCodes, HTMLEntryCodes):-
     16 	gnu_prolog,
     17 	markdown_command(CommandList),
     18 	join(CommandList, ' ', Command),
     19 	exec(Command, StreamIn, StreamOut, _),
     20 	write_codes(StreamIn, MarkdownEntryCodes),
     21 	close(StreamIn),
     22 	read_file(StreamOut, HTMLEntryCodes),
     23 	close(StreamOut).
     24 
     25 
     26 % GNU-Prolog-specific handling of dates.
     27 today(FormattedDateCodes):-
     28 	gnu_prolog,
     29 	date_time(dt(Year, Month, Day, Hour, Minute, Second)),
     30 	join([Year, '-', Month, '-', Day, ' ', Hour, ':', Minute, ':', Second], '', DateAtom),
     31 	atom_codes(DateAtom, DateCodes),
     32 	format_date(FormattedDateCodes, DateCodes).
     33 
     34 % Format a date as RFC 822 (with a four-digit year).
     35 format_date(FormattedDateCodes, DateCodes):-
     36 	gnu_prolog,
     37 	atom_codes(DateAtom, DateCodes),
     38 	join(['--date="', DateAtom, '"'], '', Arg),
     39 	join(['date', Arg, '--rfc-email'], ' ', Command),
     40 	exec(Command, _, StreamOut, _),
     41 	read_file(StreamOut, FormattedDateCodes),
     42 	close(StreamOut).