DEV Community

Cover image for palpatine 0.1.0
Batuhan Ipci
Batuhan Ipci

Posted on โ€ข Edited on

1

palpatine 0.1.0

What is palpatine?

palpatine is a minimal static site generator (SSG) built with CMake and written in C++17. It is a command line tool that takes a directory of raw data and generates a static website. It is designed to be fast, simple, and easy to use.
Palpatine is also my favorite villain, the most powerful Sith Lord ever from Star Wars.

How to use it?

After cloning the repository from github, you can build the project with CMake. If you don't have experience using CMake, don't worry, all you need to do is to run make prepare in the root directory of the project. This will run the prepare directive from the Makefile in the project and generate the executable file palpatine in the build/app directory. You can then run the executable file with ./palpatine to see the usage of the tool. Examine the Makefile to see what happens in the background.

Note: Currently, palpatine only supports txt file as input but soon it will support markdown.

Demonstration of how to use palpatine

# Clone this repository
$ git clone https://github.com/batunpc/palpatine

# Go into the repository
$ cd palpatine

# Build project w/ CMake and install dependencies 
$ make prepare

# Run the script
$ ./palpatine -i <input> -o <output> -s <stylesheet>
Enter fullscreen mode Exit fullscreen mode

Flags

Flag Description Required / Optional
-i Specify raw data directory or file e.g. use data directory in the codebase Required
-o Specify the particular directory that you want to generate static sites to. Optional
-s If you please, you can add custom stylesheets by specifying the css files.
By default it uses bahunya
Optional
-h This will display all the available options Optional

Dependencies

The following dependencies will be installed in the external directory:

  • p-ranav/argparse - A single-file header-only C++11 library for parsing command line arguments.
  • ikalnytskyi/termcolor - A header-only C++ library for printing colored messages to a terminal.

Features

  • [x] Generate a static site from a directory of text files
  • [x] Generate a stylesheet file for the static site
  • [x] Option to change the output directory
  • [x] Option to include a custom stylesheet link
  • [x] Generate a list of all pages in a directory, with links to each page
  • [x] Parse page title from the first line of the file if given

How to use external libraries in CMake?

Here is a demonstration of how I used in palpatine GitSubModules

  • i. Use this below command convenient to add external libraries to your project as a submodule. The below library is one of the libraries I used in palpatine. You can use any library you want.
 git submodule add https://github.com/p-ranav/argparse external/argparse
Enter fullscreen mode Exit fullscreen mode
  • ii. Then create cmake folder in your project. mkdir cmake (we will add CMake functions)
  • iii. Create AddGitSubmodule.cmake file in the cmake folder.
  • iv. Then add the following code to the AddGitSubmodule.cmake file:
 function(add_git_submodule dirname)
 find_package(Git REQUIRED)

 if(NOT EXISTS ${dirname}/CMakeLists.txt)
 execute_process(COMMAND ${GIT_EXECUTABLE}
 submodule update --init --recursive -- ${dirname}
 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
 )
 endif()

 add_subdirectory(${dirname})
 endfunction()
Enter fullscreen mode Exit fullscreen mode
  • v. In the root CMakeLists.txt file, add the following code to finally call the function we have written above:
 include(cmake/AddGitSubmodule.cmake)
 add_git_submodule(external/argparse) # add any library you want
Enter fullscreen mode Exit fullscreen mode
  • vi. We can link this external library we finally have added with our executable. Navigate to your app CMakeLists.txt file and add the following code:
 target_link_libraries(${EXECUTABLE_NAME} PUBLIC argparse)
Enter fullscreen mode Exit fullscreen mode

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series ๐Ÿ‘€

Watch the Youtube series

๐Ÿ‘‹ Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay