94 lines
2.3 KiB
Bash
Executable File
94 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Copyright (C) 2022 Ortega Froysa, Nicolás <nicolas@ortegas.org>
|
|
# Author: Ortega Froysa, Nicolás <nicolas@ortegas.org>
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
# License, or (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
ISIDORE_CONFIG_DIR=""
|
|
ISIDORE_CONFIG_DIR_OPTIONS=(
|
|
"$XDG_CONFIG_HOME/isidore"
|
|
"$HOME/.isidore")
|
|
ISIDORE_AUTHOR_NAME=""
|
|
|
|
##
|
|
# Create the configuration file. This function is called if it does not already
|
|
# exist.
|
|
##
|
|
function create_config_file()
|
|
{
|
|
echo "Creating $ISIDORE_CONFIG_DIR/config file..."
|
|
echo "Please enter the following..."
|
|
echo -n "Author name: "
|
|
read ISIDORE_AUTHOR_NAME
|
|
echo "ISIDORE_AUTHOR_NAME=\"$ISIDORE_AUTHOR_NAME\"" > $ISIDORE_CONFIG_DIR/config
|
|
}
|
|
|
|
##
|
|
# Read the configuration file and set the basic config variables.
|
|
##
|
|
function set_config_vars()
|
|
{
|
|
for i in "${ISIDORE_CONFIG_DIR_OPTIONS[@]}"
|
|
do
|
|
if [ -d $i ]
|
|
then
|
|
ISIDORE_CONFIG_DIR=$i
|
|
break
|
|
fi
|
|
done
|
|
|
|
if [ -z "$ISIDORE_CONFIG_DIR" ]
|
|
then
|
|
if [ -z "$XDG_CONFIG_HOME" ]
|
|
then
|
|
ISIDORE_CONFIG_DIR="$XDG_CONFIG_HOME/isidore"
|
|
else
|
|
ISIDORE_CONFIG_DIR="$HOME/.isidore"
|
|
fi
|
|
|
|
echo "Creating new Jerome configuration directory in $ISIDORE_CONFIG_DIR"
|
|
mkdir -p $ISIDORE_CONFIG_DIR
|
|
create_config_file
|
|
fi
|
|
|
|
if ! [ -f "$ISIDORE_CONFIG_DIR/config" ]
|
|
then
|
|
create_config_file
|
|
fi
|
|
source $ISIDORE_CONFIG_DIR/config
|
|
}
|
|
|
|
##
|
|
# Create a new project
|
|
#
|
|
# Params:
|
|
# $1 - The project directory
|
|
# $2 - The project name
|
|
##
|
|
function new_project()
|
|
{
|
|
NEW_PROJECT_DIR=$1
|
|
NEW_PROJECT_NAME=$2
|
|
mkdir $NEW_PROJECT_DIR
|
|
mkdir -p $NEW_PROJECT_DIR/site/
|
|
mkdir -p $NEW_PROJECT_DIR/templates/
|
|
echo "<?php
|
|
\$site_name = \"$NEW_PROJECT_NAME\";
|
|
\$author = \"$ISIDORE_AUTHOR_NAME\";
|
|
?>" >> $NEW_PROJECT_DIR/config.php
|
|
}
|
|
|
|
set_config_vars
|