<commit_before><?php

/*

# Generate Taskpaper Month

Part of the Taskpaper Tiles system by <NAME>
https://github.com/matthewmcvickar/taskpaper-month-generator

Creates a month list for the requested month and year (or the current month and year, if unspecified) in TaskPaper, populating days with items as specified in the plaintext hierarchy below.

*/

// If a new 'items' value was set, update the cookie. Expiration is one year, and should always be enough, since this will be set by this script running at least once a month.
if ($_REQUEST['items_text'])
{
  setcookie('items', $_REQUEST['items_text'], time() + 315569260);

  // Reload the page, since we just set a cookie.
  header('Location: ' . $_SERVER['SCRIPT_NAME']);
}

// If the cookie exists, get its value. Otherwise populate the items with sample data.
if ($_COOKIE['items'])
  $items_plaintext = $_COOKIE['items'];
else
  $items_plaintext = "1\nfoo bar baz\n\n14\nlorem ipsum\n\n30\ndolor sit\namet\nadispicium";

// Create a flat array from the plain text in the cookie above by splitting it by newlines that contain a number.
$items_array = preg_split('~\n([0-9]+)~', "\n" . $items_plaintext, NULL, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);

// Build a multidimensional array from the flat one by iterating through odd and even numbers in the array.
foreach (range(0, count($items_array) - 1, 2) as $key)
  $items[$items_array[$key]] = $items_array[$key + 1];

// Turn the list within each day into an array by splitting it by newlines.
foreach ($items as $key => $value)
  $items[$key] = explode("\n", trim($value));

// Set timezone so that PHP doesn't freak out.
date_default_timezone_set('UTC');

?><!doctype html>

<html>
  <head>
    <title>Taskpaper Month Generator</title>
    <style>
    html,
    body
    {
      height: 100%;
      margin: 0;
      padding: 0;<commit_msg>Better example text.<commit_after><?php

/*

# Generate Taskpaper Month

Generator: http://taskpaper-month-generator.herokuapp.com
Source:    https://github.com/matthewmcvickar/taskpaper-month-generator

Part of the Taskpaper Tiles system by <NAME>
https://github.com/matthewmcvickar/taskpapertiles

Creates a month list for the requested month and year (or the current month and year, if unspecified) in TaskPaper, populating days with items as specified in the plaintext hierarchy below.

*/

// If a new 'items' value was set, update the cookie. Expiration is one year, and should always be enough, since this will be set by this script running at least once a month.
if ($_REQUEST['items_text'])
{
  setcookie('items', $_REQUEST['items_text'], time() + 315569260);

  // Reload the page, since we just set a cookie.
  header('Location: ' . $_SERVER['SCRIPT_NAME']);
}

// If the cookie exists, get its value. Otherwise populate the items with sample data.
if ($_COOKIE['items'])
  $items_plaintext = $_COOKIE['items'];
else
  $items_plaintext = "1\nto-do item\n\n14\nappointment reminder\n  details of appointment\n\n29\ntask\nanother task\n  a note for this task\n  another note";

// Create a flat array from the plain text in the cookie above by splitting it by newlines that contain a number.
$items_array = preg_split('~\n([0-9]+)~', "\n" . $items_plaintext, NULL, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);

// Build a multidimensional array from the flat one by iterating through odd and even numbers in the array.
foreach (range(0, count($items_array) - 1, 2) as $key)
  $items[$items_array[$key]] = $items_array[$key + 1];

// Turn the list within each day into an array by splitting it by newlines.
foreach ($items as $key => $value)
  $items[$key] = explode("\n", trim($value));

// Set timezone so that PHP doesn't freak out.
date_default_timezone_set('UTC');

?><!doctype html>

<html>
  <head>
    <title>Taskpaper Month Generator</title>
    <style>
    html,
    body
    {
      height: 100%;
      margin: 0;
      padding: 0;
{'fraction_non_alphanumeric': 0.11874361593462716, 'fraction_numerical': 0.012768130745658836, 'mean_word_length': 4.100260416666667, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, 'https://': 3, 'lorem ipsum': 1, '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': '5024441', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1232, 'n_words': 458}