App-WRT

 view release on metacpan or  search on metacpan

bin/wrt-init  view on Meta::CPAN


print_help() {
  echo "wrt-init - initialize a stub wrt repository"
  echo
  echo "Usage:"
  echo "        wrt-init [target directory]"
  echo
  echo "Creates a configuration file, a basic template, and archive and"
  echo "publication directories in a given path for use with wrt."
  echo
  echo "If no path is given, the current working directory will be assumed."
  exit 1
}

if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
  print_help
fi

init_target="."
if [ "$1" ]; then
  init_target="$1"
fi

echo "Initializing new wrt repository in $init_target"

if [ ! -e "$init_target" ]; then
  echo "$init_target not found"
  exit 66
fi

if [ ! -d "$init_target" ]; then
  echo "$init_target is not a directory"
  exit 73
fi

if [ -e "$init_target/wrt.json" ]; then
  echo "$init_target/wrt.json already exists"
  exit 73
fi

printf 'Entries:\t%s/archives/\n' "$init_target"
mkdir -p "$init_target/archives"

printf 'Entries:\t%s/filters/\n' "$init_target"
mkdir -p "$init_target/filters"

printf 'Publish to:\t%s/public/\n' "$init_target"
mkdir -p "$init_target/public"

printf 'Configuration:\t%s/wrt.json\n' "$init_target"
cat > "$init_target/wrt.json" << 'JSON'
{
   "entry_dir": "./archives",
   "filter_dir": "./filters",
   "publish_dir": "./public",
   "title_prefix": "your title here",
   "template": "default",
   "description": "a wrt site",
   "url_root": "https://example.com/",
   "image_url_root": "https://example.com/",
   "favicon_url": "https://example.com/favicon.png",
   "template_dir": "./templates",
   "stylesheet_url": "https://example.com/css/wrt.css",
   "author": "Your Name Here",
   "entry_descriptions": {
     "new": "newest entries",
     "all": "all entries"
   }
}
JSON

printf 'Template:\t%s/templates/default\n' "$init_target"
mkdir -p "$init_target/templates"

cat > "$init_target/templates/default" << 'HTML'
<!DOCTYPE html>
<html>
<head>
  <title>${title_prefix}::${title}</title>
  <meta name="keywords" content="keywords here" />
  <meta name="description" content="${description}" /> 
  <meta name="author" content="${author}" />
  <link rel="stylesheet" href="${stylesheet_url}" />
  <link rel="icon" type="image/x-png" href="${favicon_url}" />
  <link rel=alternate type="application/atom+xml" title="${title_prefix} atom feed" href="${url_root}${feed_alias}" />
  <link rel=feed type="application/atom+xml" title="${title_prefix} atom feed" href="${url_root}${feed_alias}" />
  <link rel="alternate" title="${title_prefix} JSON feed" type="application/json" href="${url_root}${feed_alias}.json" />
</head>

<body>

<perl>
  return $self->link_bar();
</perl>

<h1>${title}</h1>

${content}

${page_navigation}

<p><small><em>${license}</em></small></p>

</body>
</html>
HTML



( run in 0.624 second using v1.01-cache-2.11-cpan-df04353d9ac )