diff options
Diffstat (limited to '')
-rwxr-xr-x | seen.sh | 32 |
1 files changed, 9 insertions, 23 deletions
@@ -5,12 +5,7 @@ # it under the terms of the GNU 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 General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <https://www.gnu.org/licenses/>. +# Please see the LICENSE file for more details. usage() { echo "Usage : ./seen [OPTIONS]" echo "--help : Print this help message" @@ -45,18 +40,14 @@ else usage exit 1 fi -# Create the www/ folder if removed -mkdir -p "www" || die "Cannot create www/ directory: mkdir -p returns an error!" -# Erase www/index.html and insert the header -cat "templates/header.html" > www/index.html || die "Cannot insert header into index.html!" -# Detect articles -articles="$(find articles/*.md|sed -e 's@.md@@g' -e 's@articles/@@g')" || die "Unknown error" +mkdir -p "www" || die "Cannot create www/ directory: mkdir -p returns an error!" # Create the www/ folder if removed +cat "templates/header.html" > www/index.html || die "Cannot insert header into index.html!" # Erase www/index.html and insert the header +articles="$(find articles/*.md|sed -e 's@.md@@g' -e 's@articles/@@g')" || die "Unknown error" # Detect articles # Set the defaults name="(!) no name (!)" desc="(!) no description (!)" date="1st January 1970" -# In the 'for' loop -for line in ${articles} +for line in ${articles} # In the 'for' loop do . "articles/${line}.cfg" || die "Cannot read ${line}.cfg file!" # Override the defaults mkdir "www/articles" -p @@ -64,14 +55,9 @@ do markdown "articles/${line}.md" >> "www/articles/${line}.html" || hoedown "articles/${line}.md" >> "www/articles/${line}.html" || die "Cannot convert ${line}.md to html!" # Convert the markdown text to html cat "templates/footer.html" >> "www/articles/${line}.html" || die "Cannot insert footer into ${line}.html!" # Insert the footer into the article page cp -r templates/*.css www/. # Add css files if present - # Add an entry in index.html - echo "-> [$(date +%R)] Adding ${line} entry to index.html ..." - sed \ - -e "s@path-of-article@articles/${line}@" \ - -e "s@name-of-article@${name}@" \ - -e "s@date-of-article@${date}@" \ - -e "s@description-of-article@${desc}@" \ + echo "-> [$(date +%R)] Adding ${line} entry to index.html ..." # Add an entry in index.html + sed -e "s@path-of-article@articles/${line}@" -e "s@name-of-article@${name}@" \ + -e "s@date-of-article@${date}@" -e "s@description-of-article@${desc}@" \ "templates/article.html">> "www/index.html" || die "Cannot add entry to index.html!" done -# Insert the footer into the index.html -cat "templates/footer.html" >> "www/index.html" +cat "templates/footer.html" >> "www/index.html" # Insert the footer into the index.html |