From f56df1025b21870b39afd10634f895443d1d3a6b Mon Sep 17 00:00:00 2001 From: bamr87 <10567847+bamr87@users.noreply.github.com> Date: Mon, 10 Jun 2024 21:09:59 -0700 Subject: [PATCH 1/5] updating seed --- zer0.md | 180 +++++++++++--------------------------------------------- 1 file changed, 35 insertions(+), 145 deletions(-) diff --git a/zer0.md b/zer0.md index 5968fb9..1a12d79 100644 --- a/zer0.md +++ b/zer0.md @@ -30,13 +30,18 @@ snippet: What is a snippet? comments: true --- +{{ site.url_test }} + +[![pages-build-deployment](https://github.com/bamr87/zer0-mistakes/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/bamr87/zer0-mistakes/actions/workflows/pages/pages-build-deployment) + +[![Gem Version](https://badge.fury.io/rb/jekyll-theme-zer0.svg)](https://badge.fury.io/rb/jekyll-theme-zer0) + This is the seed of the project with all the commands, scripts, and instructions that build this application from the ground up. In theory, this should be the only file you need to build the project from scratch. However, in practice, you may need to install additional dependencies or configure the environment to match the target system. For example, you may need to install Ruby, Node.js, or other tools to run the application locally or deploy it to a server. Therefore, part of this document is to provide a list of prerequisites and setup instructions to help you get started with the project. -[![Gem Version](https://badge.fury.io/rb/jekyll-theme-zer0.svg)](https://badge.fury.io/rb/jekyll-theme-zer0) ## System Specs @@ -212,7 +217,7 @@ git remote add origin https://github.com/${GHUSER}/${GIT_REPO}.git git pull origin main curl https://raw.githubusercontent.com/bamr87/it-journey/master/zer0.md > README.md git add README.md -git commit -m "Init zer0-mistakes" +git commit -m "Init $GIT_REPO" git branch -M main git push -u origin main ``` @@ -245,6 +250,7 @@ touch Gemfile echo 'source "https://rubygems.org"' >> Gemfile echo "gem 'github-pages' , '231'" >> Gemfile echo "gem 'jekyll' , '3.9.5'" >> Gemfile +echo "gem 'jekyll-theme-zer0' , '0.1.2'" >> Gemfile echo "group :jekyll_plugins do" >> Gemfile echo " gem 'jekyll-feed', \"~> 0.17\"" >> Gemfile echo " gem 'jekyll-sitemap' , \"~> 1.4.0\"" >> Gemfile @@ -253,6 +259,27 @@ echo " gem 'jekyll-paginate', '~> 1.1'" >> Gemfile echo "end" >> Gemfile ``` +### Configure Jekyll + +```shell +code _config.yml +``` + +```yaml +theme: jekyll-theme-zer0 + +title: zer0-mistakes +email: bamr87@zer0-mistakes.com +description: >- # this means to ignore newlines until "baseurl:" + Write an awesome description for your new site here. You can edit this + line in _config.yml. It will appear in your document head meta (for + Google search results) and in your feed.xml site description. +baseurl: null # the subpath of your site, e.g. /blog +url: null # the base hostname & protocol for your site, e.g. http://example.com +twitter_username: bamr87 +github_username: bamr87 +``` + ### Create Dockerfile ```shell @@ -301,18 +328,6 @@ open http://localhost:4000/ ![](/assets/images/zer0-checkpoint-2.png) -## Install Jekyll - -Install [jekyll](https://jekyllrb.com/docs/installation/) - -```shell -jekyll new ./ --force -bundle install -``` - -## Checkpoint - Jekyll Initialized - - ```shell code _config.yml ``` @@ -330,137 +345,6 @@ twitter_username: bamr87 github_username: bamr87 ``` - - -```shell -cd $ZREPO -wget https://raw.githubusercontent.com/bamr87/it-journey/master/favicon.ico -``` - -## Install Jekyll - -Install [jekyll](https://jekyllrb.com/docs/installation/) - -```shell -docker run jekyll new ./ --force -bundle install -``` - -## Checkpoint - Jekyll Initialized - -```shell -code _config.yml -``` - -```yaml -title: zer0-mistakes -email: bamr87@zer0-mistakes.com -description: >- # this means to ignore newlines until "baseurl:" - Write an awesome description for your new site here. You can edit this - line in _config.yml. It will appear in your document head meta (for - Google search results) and in your feed.xml site description. -baseurl: null # the subpath of your site, e.g. /blog -url: null # the base hostname & protocol for your site, e.g. http://example.com -twitter_username: bamr87 -github_username: bamr87 -``` - - - -```shell -cd $ZREPO -wget https://raw.githubusercontent.com/bamr87/it-journey/master/favicon.ico -``` - -## Checkpoint 1 - -```shell - -bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32 java -``` - -### Override default -https://jekyllrb.com/docs/themes/#overriding-theme-defaults - -```shell -# find theme path - -bundle info --path minima -JEKYLL_THEME=$(bundle info --path minima) -echo $JEKYLL_THEME -cd $JEKYLL_THEME -``` - -### Copy theme repo - -```shell -cp -aR $JEKYLL_THEME/* $ZREPO -``` - -### Remove Theme plugin - -```shell -bundle remove jekyll-theme-minima -``` - -### Comment out the theme from config and Gemfile - -```shell -#_config.yml -# Build settings -# theme: minima -plugins: - - jekyll-feed -``` - -```shell -bundle remove minima --install -``` - -Restart jekyll -```shell -jekyll serve -``` - -## Building the theme - -### Build default page - -```shell -{%- raw -%} -cd $ZREPO -mkdir _layout -cd _layout -echo "{{ content }}" >> default.html -{% endraw %} -``` - - -```shell -#tree #alias #zshrc #profile -alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'" -echo alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'" >> ~/.zshrc - -tree -cd - -``` - - -## Plant the seed - -```shell -# Set the date format -d=$(date +%Y-%m-%d) -echo "$d" -``` - -```shell -# Download the seed page -cd $ZREPO -wget -O $d-zer0.md https://raw.githubusercontent.com/bamr87/it-journey/master/zer0.md -``` - - ## Convert zer0.md to zer0.sh using Python ```python @@ -497,3 +381,9 @@ def convert_md_to_files(md_file_path): convert_md_to_files('zer0.md') ``` + +## Config file + +```yaml +{% include_relative _config.yml %} +``` \ No newline at end of file From 21de486438bfef2ffcc8906f9b941226688aac02 Mon Sep 17 00:00:00 2001 From: bamr87 <10567847+bamr87@users.noreply.github.com> Date: Mon, 10 Jun 2024 22:01:14 -0700 Subject: [PATCH 2/5] zer0 progress --- zer0.md | 139 ++++++++++---------------------------------------------- 1 file changed, 24 insertions(+), 115 deletions(-) diff --git a/zer0.md b/zer0.md index 1a12d79..d6a0ca6 100644 --- a/zer0.md +++ b/zer0.md @@ -42,7 +42,6 @@ However, in practice, you may need to install additional dependencies or configu For example, you may need to install Ruby, Node.js, or other tools to run the application locally or deploy it to a server. Therefore, part of this document is to provide a list of prerequisites and setup instructions to help you get started with the project. - ## System Specs For my development machine, I use the following specs: @@ -125,13 +124,13 @@ brew install --cask visual-studio-code ## Environment -### Set your own environment variables +### Enter Variables {% if site.level == 'her0' %} {% include zer0-env-var.html %} {% endif %} -### Set the default environment variables +### Or use default ```shell # Or use the following to set the environment variables @@ -142,57 +141,33 @@ export GIT_REPO=zer0-mistakes export ZREPO=$GITHOME/$GIT_REPO ``` -### Add the environment variables to your shell profile (optional) - ```shell -#open Code to edit your shell profile and copy the environment variables +# Confirm the environment variables by echoing them and logging them to a file -code ~/.zprofile +echo "$(date) - Log started" > env-variables.log +echo -e "GITHOME: $GITHOME\nGHUSER: $GHUSER\nGIT_REPO: $GIT_REPO\nZREPO: $ZREPO" >> env-variables.log ``` -```shell -# Confirm the environment variables by echoing them - -echo $GITHOME # /Users/bamr87/github -echo $GHUSER # bamr87 -echo $GIT_REPO # zer0-mistakes -echo $ZREPO # /Users/bamr87/github/zer0-mistakes -``` - -### Set your Git email and name +### Set Git email and username ```shell # Set your Git email and name to tag your commits +# If the GIT_ID is set, use it to tag your commits. "https://github.com/settings/emails" -git config --global user.email "$GHUSER@users.noreply.github.com" git config --global user.name "$GHUSER" -``` - -### Set your GitHub email using ID (optional) - -See [here](https://github.com/settings/emails) for details. - -```shell -# If you didnt already set it in the previous step -# FIXME: quotes in comments dont work - -echo "What is your Github ID?" -read GIT_ID -``` - -```shell -# Set your email using ID - -git config --global user.email "$GIT_ID+$GHUSER@users.noreply.github.com" +git config --global user.email "$GHUSER@users.noreply.github.com" +if [ -n "$GIT_ID" ]; then + git config --global user.email "$GIT_ID+$GHUSER@users.noreply.github.com" +fi ``` ```shell # confirm your email -git config -l +git config -l | tee -a env-variables.log ``` -## Initialize your new github repository +## Initialize github [gh cli docs](https://cli.github.com/manual/) @@ -215,6 +190,11 @@ cd $ZREPO git init git remote add origin https://github.com/${GHUSER}/${GIT_REPO}.git git pull origin main + +``` + +```shell +# Create a README.md file based on the zer0.md file from this repo curl https://raw.githubusercontent.com/bamr87/it-journey/master/zer0.md > README.md git add README.md git commit -m "Init $GIT_REPO" @@ -222,7 +202,7 @@ git branch -M main git push -u origin main ``` -### Checkpoint - Github Repo Initialized +### Checkpoint - Github Repo Go to your new github repository. @@ -255,29 +235,16 @@ echo "group :jekyll_plugins do" >> Gemfile echo " gem 'jekyll-feed', \"~> 0.17\"" >> Gemfile echo " gem 'jekyll-sitemap' , \"~> 1.4.0\"" >> Gemfile echo " gem 'jekyll-seo-tag', \"~> 2.8.0\"" >> Gemfile -echo " gem 'jekyll-paginate', '~> 1.1'" >> Gemfile +echo " gem 'jekyll-paginate', \"'~> 1.1'\"" >> Gemfile echo "end" >> Gemfile ``` -### Configure Jekyll +### Download Config file ```shell -code _config.yml -``` +# Download the _config.yml file from the jekyll-theme-zer0 repo -```yaml -theme: jekyll-theme-zer0 - -title: zer0-mistakes -email: bamr87@zer0-mistakes.com -description: >- # this means to ignore newlines until "baseurl:" - Write an awesome description for your new site here. You can edit this - line in _config.yml. It will appear in your document head meta (for - Google search results) and in your feed.xml site description. -baseurl: null # the subpath of your site, e.g. /blog -url: null # the base hostname & protocol for your site, e.g. http://example.com -twitter_username: bamr87 -github_username: bamr87 +curl https://raw.githubusercontent.com/bamr87/zer0-mistakes/main/_config.yml > _config.yml ``` ### Create Dockerfile @@ -316,72 +283,14 @@ docker run -d -p 4000:4000 -v ${ZREPO}:/app --name zer0_container ${GIT_REPO} # Start the container and run the CMD line from the Dockerfile docker start zer0_container -# Attach to the running container -docker exec -it zer0_container /bin/bash ``` -## Checkpoint - Jekyll Initialized +## Checkpoint - Jekyll ```shell open http://localhost:4000/ ``` -![](/assets/images/zer0-checkpoint-2.png) - -```shell -code _config.yml -``` - -```yaml -title: zer0-mistakes -email: bamr87@zer0-mistakes.com -description: >- # this means to ignore newlines until "baseurl:" - Write an awesome description for your new site here. You can edit this - line in _config.yml. It will appear in your document head meta (for - Google search results) and in your feed.xml site description. -baseurl: null # the subpath of your site, e.g. /blog -url: null # the base hostname & protocol for your site, e.g. http://example.com -twitter_username: bamr87 -github_username: bamr87 -``` - -## Convert zer0.md to zer0.sh using Python - -```python -def convert_md_to_files(md_file_path): - language_files = {} - language_mode = None - language_extensions = {'python': '.py', 'shell': '.sh'} - shebang_lines = {'python': '#!/usr/bin/env python3\n', 'shell': '#!/bin/bash\n'} - - with open(md_file_path, 'r') as md_file: - for line in md_file: - if line.startswith('```'): - if language_mode: - # End of a language block, switch back to markdown mode - language_mode = None - else: - # Start of a language block, open a new file for this language if not already open - language = line.strip('`\n') - if language in language_extensions: - language_mode = language - if language not in language_files: - language_file = open(md_file_path.replace('.md', language_extensions[language]), 'w') - if language in shebang_lines: - language_file.write(shebang_lines[language]) - language_files[language] = language_file - continue - - if language_mode: - language_files[language_mode].write(line) - - # Close all open language files - for language_file in language_files.values(): - language_file.close() - -convert_md_to_files('zer0.md') -``` - ## Config file ```yaml From 650ab3bd2a038f04a76daf4c8ceb2e64fbb7987e Mon Sep 17 00:00:00 2001 From: bamr87 <10567847+bamr87@users.noreply.github.com> Date: Mon, 10 Jun 2024 22:17:48 -0700 Subject: [PATCH 3/5] zer0 recursion --- script/zer0.py | 46 +++++++++----- script/zer0.sh | 134 +++++++++++++++++++--------------------- script/zer0_md_to_sh.py | 46 +++++++++----- zer0.md | 40 ++++++++++++ 4 files changed, 168 insertions(+), 98 deletions(-) diff --git a/script/zer0.py b/script/zer0.py index 724ec1e..695ea6f 100644 --- a/script/zer0.py +++ b/script/zer0.py @@ -1,18 +1,36 @@ #!/usr/bin/env python3 -def convert_md_to_bash(md_file_path, bash_file_path): - with open(md_file_path, 'r') as md_file, open(bash_file_path, 'w') as bash_file: - bash_file.write('#!/bin/bash\n') # add shebang line - shell_script_mode = False +import os + +def convert_md_to_files(md_file_path): + language_files = {} + language_mode = None + language_extensions = {'python': '.py', 'shell': '.sh'} + shebang_lines = {'python': '#!/usr/bin/env python3\n', 'shell': '#!/bin/bash\n'} + + output_folder = "script" + os.makedirs(output_folder, exist_ok=True) + + with open(md_file_path, 'r') as md_file: for line in md_file: - if '```shell' in line: - shell_script_mode = True + if line.startswith('```'): + if language_mode: + language_mode = None + else: + language = line.strip('`\n') + if language in language_extensions: + language_mode = language + if language not in language_files: + output_file_path = os.path.join(output_folder, os.path.basename(md_file_path).replace('.md', language_extensions[language])) + language_file = open(output_file_path, 'w') + if language in shebang_lines: + language_file.write(shebang_lines[language]) + language_files[language] = language_file continue - elif '```' in line and shell_script_mode: - shell_script_mode = False - continue - if shell_script_mode: - bash_file.write(line) - else: - bash_file.write(f'# {line}') -convert_md_to_bash('zer0.md', 'zer0.sh') + if language_mode: + language_files[language_mode].write(line) + + for language_file in language_files.values(): + language_file.close() + +convert_md_to_files('zer0.md') diff --git a/script/zer0.sh b/script/zer0.sh index 9b6807d..5e6e3e4 100644 --- a/script/zer0.sh +++ b/script/zer0.sh @@ -5,9 +5,10 @@ system_profiler SPHardwareDataType | awk '/Model Name:|Model Identifier:|Model N system_profiler SPSoftwareDataType | awk '/System Version:|Kernel Version:/ {print $0}' # install and update prerequisites + brew install git brew install gh -brew install docker +brew install --cask docker brew install --cask visual-studio-code # Or use the following to set the environment variables @@ -15,94 +16,87 @@ export GITHOME=~/github export GHUSER=bamr87 export GIT_REPO=zer0-mistakes export ZREPO=$GITHOME/$GIT_REPO +# Confirm the environment variables by echoing them and logging them to a file -# Confirm the environment variables by echoing them - -echo $GITHOME # /Users/bamr87/github -echo $GHUSER # bamr87 -echo $GIT_REPO # zer0-mistakes -echo $ZREPO # /Users/bamr87/github/zer0-mistakes +echo "$(date) - Log started" > env-variables.log +echo -e "GITHOME: $GITHOME\nGHUSER: $GHUSER\nGIT_REPO: $GIT_REPO\nZREPO: $ZREPO" >> env-variables.log # Set your Git email and name to tag your commits +# If the GIT_ID is set, use it to tag your commits. "https://github.com/settings/emails" -git config --global user.email "$GHUSER@users.noreply.github.com" git config --global user.name "$GHUSER" -# If you didnt already set it in the previous step -# FIXME: quotes in comments dont work - -echo "What is your Github ID?" -read GIT_ID - -# Set your email using ID - -git config --global user.email "$GIT_ID+$GHUSER@users.noreply.github.com" +git config --global user.email "$GHUSER@users.noreply.github.com" +if [ -n "$GIT_ID" ]; then + git config --global user.email "$GIT_ID+$GHUSER@users.noreply.github.com" +fi # confirm your email -git config -l - -# Initialize your github repository - -gh repo create $GHUSER/$GIT_REPO --public +git config -l | tee -a env-variables.log # Create your github home directory and repo mkdir -p $ZREPO +# Initialize your github repository + +gh repo create $GIT_REPO --gitignore Jekyll -l mit --public # If new repo, initialize it cd $ZREPO git init -echo "# Building new report from $ZREPO" >> README.md +git remote add origin https://github.com/${GHUSER}/${GIT_REPO}.git +git pull origin main + +# Create a README.md file based on the zer0.md file from this repo +curl https://raw.githubusercontent.com/bamr87/it-journey/master/zer0.md > README.md git add README.md -git commit -m "first commit" +git commit -m "Init $GIT_REPO" git branch -M main -git remote add origin https://github.com/${GHUSER}/${GIT_REPO}.git git push -u origin main - # Open your new github repository in the browser open https://github.com/${GHUSER}/${GIT_REPO} +# Create a new Gemfile cd $ZREPO -jekyll new ./ --force -bundle install -# If running MacOS -bundle add webrick -bundle install -jekyll serve -cd $ZREPO -bundle update -bundle install -jekyll serve -code _config.yml -cd $ZREPO -wget https://raw.githubusercontent.com/bamr87/it-journey/master/favicon.ico -bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32 java -# find theme path -bundle info --path minima -JEKYLL_THEME=$(bundle info --path minima) -echo $JEKYLL_THEME -cd $JEKYLL_THEME - -cp -aR $JEKYLL_THEME/* $ZREPO -bundle remove jekyll-theme-minima -#_config.yml -# Build settings -# theme: minima -plugins: - - jekyll-feed -bundle remove minima --install -jekyll serve -{%- raw -%} +touch Gemfile + +# Write the non-commented lines to the Gemfile +echo 'source "https://rubygems.org"' >> Gemfile +echo "gem 'github-pages' , '231'" >> Gemfile +echo "gem 'jekyll' , '3.9.5'" >> Gemfile +echo "gem 'jekyll-theme-zer0' , '0.1.2'" >> Gemfile +echo "group :jekyll_plugins do" >> Gemfile +echo " gem 'jekyll-feed', \"~> 0.17\"" >> Gemfile +echo " gem 'jekyll-sitemap' , \"~> 1.4.0\"" >> Gemfile +echo " gem 'jekyll-seo-tag', \"~> 2.8.0\"" >> Gemfile +echo " gem 'jekyll-paginate', \"'~> 1.1'\"" >> Gemfile +echo "end" >> Gemfile +# Download the _config.yml file from the jekyll-theme-zer0 repo + +curl https://raw.githubusercontent.com/bamr87/zer0-mistakes/main/_config.yml > _config.yml +# Create a new Dockerfile cd $ZREPO -mkdir _layout -cd _layout -echo "{{ content }}" >> default.html -{% endraw %} -#tree #alias #zshrc #profile -alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'" -echo alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'" >> ~/.zshrc - -tree -cd - -d=$(date +%Y-%m-%d) -echo "$d" -cd $ZREPO/_posts -wget -O $d-home.md https://raw.githubusercontent.com/bamr87/it-journey/master/home.md +touch Dockerfile + +# Write the content to the Dockerfile +echo "# Use an official Ruby runtime as a parent image" >> Dockerfile +echo "FROM ruby:2.7.4" >> Dockerfile +echo "# escape=\\" >> Dockerfile +echo "ENV GITHUB_GEM_VERSION 231" >> Dockerfile +echo "ENV JSON_GEM_VERSION 1.8.6" >> Dockerfile +echo "ENV GIT_REPO ${GIT_REPO}" >> Dockerfile +echo "WORKDIR /app" >> Dockerfile +echo "ADD . /app" >> Dockerfile +echo "RUN gem update --system 3.3.22" >> Dockerfile +echo "RUN bundle update" >> Dockerfile +echo "RUN bundle install" >> Dockerfile +echo "RUN bundle clean --force" >> Dockerfile +echo "EXPOSE 4000" >> Dockerfile +echo 'CMD ["bundle", "exec", "jekyll", "serve", "--host", "0.0.0.0"]' >> Dockerfile +# build the docker image based on the Dockerfile +docker build -t ${GIT_REPO} . +# Run the container in detached mode +docker run -d -p 4000:4000 -v ${ZREPO}:/app --name zer0_container ${GIT_REPO} + +# Start the container and run the CMD line from the Dockerfile +docker start zer0_container + +open http://localhost:4000/ diff --git a/script/zer0_md_to_sh.py b/script/zer0_md_to_sh.py index 26b5861..775ae11 100644 --- a/script/zer0_md_to_sh.py +++ b/script/zer0_md_to_sh.py @@ -1,17 +1,35 @@ -def convert_md_to_bash(md_file_path, bash_file_path): - with open(md_file_path, 'r') as md_file, open(bash_file_path, 'w') as bash_file: - bash_file.write('#!/bin/bash\n') # add shebang line - shell_script_mode = False +import os + +def convert_md_to_files(md_file_path): + language_files = {} + language_mode = None + language_extensions = {'python': '.py', 'shell': '.sh'} + shebang_lines = {'python': '#!/usr/bin/env python3\n', 'shell': '#!/bin/bash\n'} + + output_folder = "script" + os.makedirs(output_folder, exist_ok=True) + + with open(md_file_path, 'r') as md_file: for line in md_file: - if '```shell' in line: - shell_script_mode = True + if line.startswith('```'): + if language_mode: + language_mode = None + else: + language = line.strip('`\n') + if language in language_extensions: + language_mode = language + if language not in language_files: + output_file_path = os.path.join(output_folder, os.path.basename(md_file_path).replace('.md', language_extensions[language])) + language_file = open(output_file_path, 'w') + if language in shebang_lines: + language_file.write(shebang_lines[language]) + language_files[language] = language_file continue - elif '```' in line and shell_script_mode: - shell_script_mode = False - continue - if shell_script_mode: - bash_file.write(line) - else: - bash_file.write(f'# {line}') -convert_md_to_bash('zer0.md', 'zer0.sh') \ No newline at end of file + if language_mode: + language_files[language_mode].write(line) + + for language_file in language_files.values(): + language_file.close() + +convert_md_to_files('zer0.md') \ No newline at end of file diff --git a/zer0.md b/zer0.md index d6a0ca6..1eafec5 100644 --- a/zer0.md +++ b/zer0.md @@ -291,6 +291,46 @@ docker start zer0_container open http://localhost:4000/ ``` +## Python Script + +```python +import os + +def convert_md_to_files(md_file_path): + language_files = {} + language_mode = None + language_extensions = {'python': '.py', 'shell': '.sh'} + shebang_lines = {'python': '#!/usr/bin/env python3\n', 'shell': '#!/bin/bash\n'} + + output_folder = "script" + os.makedirs(output_folder, exist_ok=True) + + with open(md_file_path, 'r') as md_file: + for line in md_file: + if line.startswith('```'): + if language_mode: + language_mode = None + else: + language = line.strip('`\n') + if language in language_extensions: + language_mode = language + if language not in language_files: + output_file_path = os.path.join(output_folder, os.path.basename(md_file_path).replace('.md', language_extensions[language])) + language_file = open(output_file_path, 'w') + if language in shebang_lines: + language_file.write(shebang_lines[language]) + language_files[language] = language_file + continue + + if language_mode: + language_files[language_mode].write(line) + + for language_file in language_files.values(): + language_file.close() + +convert_md_to_files('zer0.md') +``` + ## Config file ```yaml From 86815f361ea89742de13091e55d9a7aff2d30a6a Mon Sep 17 00:00:00 2001 From: bamr87 <10567847+bamr87@users.noreply.github.com> Date: Mon, 10 Jun 2024 22:23:32 -0700 Subject: [PATCH 4/5] clean --- _config.yml | 3 ++- zer0.md | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/_config.yml b/_config.yml index ce22ade..0a88f3d 100644 --- a/_config.yml +++ b/_config.yml @@ -27,6 +27,7 @@ # Site Settings ################################################################### founder : "Amr Abdel-Motaleb" +remote_theme : "bamr87/zer0-mistakes" ### Github Information github_user : &github_user "bamr87" @@ -52,7 +53,7 @@ domain_ext : ".dev" sub_domain : &sub_domain "" baseurl : "" # the subpath of your site, e.g. /blog - Use this if you want this whole repo to be a domain branch url_dev : ['https://', *sub_domain, '.', *domain, *domain_ext ] # the base hostname & protocol for your site, e.g. http://example.com -url : 'https://bamr87.github.io' # the base hostname & protocol for your site, e.g. http://example.com +url : 'https://it-journey.dev' # the base hostname & protocol for your site, e.g. http://example.com public_folder : "/assets" port : 4002 # Jekyll Serve Dev port dg_port : 4001 # TODO: Doppelganger site. Use this if you want to switch between parallel deployments diff --git a/zer0.md b/zer0.md index 1eafec5..b0783e9 100644 --- a/zer0.md +++ b/zer0.md @@ -335,4 +335,10 @@ convert_md_to_files('zer0.md') ```yaml {% include_relative _config.yml %} -``` \ No newline at end of file +``` + +## Scripts + +```shell +{% include_relative script/zer0.sh %} +``` From 83dd1258c3fd1045ab58957b87044ac635aec6e1 Mon Sep 17 00:00:00 2001 From: bamr87 Date: Tue, 11 Jun 2024 21:20:36 -0700 Subject: [PATCH 5/5] config fixes --- _config.yml | 18 ++++++------------ script/zer0.sh | 15 ++++++++++----- zer0.md | 26 +++++++++++++++++--------- 3 files changed, 33 insertions(+), 26 deletions(-) mode change 100644 => 100755 script/zer0.sh diff --git a/_config.yml b/_config.yml index 0a88f3d..ab936fa 100644 --- a/_config.yml +++ b/_config.yml @@ -28,8 +28,9 @@ founder : "Amr Abdel-Motaleb" remote_theme : "bamr87/zer0-mistakes" +theme : "jekyll-theme-zer0" -### Github Information +## Github Information github_user : &github_user "bamr87" repository_name : &github_repository "it-journey" repository : [*github_user, "/", *github_repository] # GitHub username/repo-name @@ -84,7 +85,7 @@ locale : "en-US" home_dir : &home '/Users/bamr87/' local_git : [ *home, 'github' ] logo : /assets/images/gravatar-small.png # path of logo image to display in the masthead, e.g. "/assets/images/88x88.png" -logo_link : 'https://www.it-journey.dev' +logo_link : [ *url, *baseurl ] # URL to link the logo to, e.g. "/" teaser : /assets/images/favicon_gpt_computer_retro.png # path of fallback teaser image, e.g. "/assets/images/500x300.png" info_banner : /assets/images/info-banner-mountain-wizard.png # path of fallback teaser image, e.g. "/assets/images/500x300.png" @@ -189,7 +190,7 @@ plugins: - jekyll-sitemap - jekyll-seo-tag - jekyll-paginate - # - jekyll-algolia + - jekyll-relative-links ## Gisgus Plugin ################################################################# @@ -266,8 +267,6 @@ paginate_path: "/pages/:num/" # Defaults https://jekyllrb.com/docs/configuration/front-matter-defaults/ -nav-file: '_data/navigation/map.yml' - defaults: # ALL - @@ -324,7 +323,7 @@ defaults: sidebar: nav: quickstart - # _posts + # pages/_posts - scope: path: pages/_posts @@ -428,9 +427,6 @@ algolia: search_only_api_key: '3b9200e21085fbebc263950c157b2682' index_name: dev_it-journey -atom_feed: -path : # blank (default) uses feed.xml - ## Style Settings ------------------------------------------------------------- # theme : "zer0-mistakes-jekyll" @@ -440,8 +436,6 @@ theme_skin : "dark" # "air", "aqua", "contrast", "dark", "dirt", " # style : "default" # "default", "dark", "light", "solarized-dark", "solarized-light" # remote_style : "bamr87/zer0-mistakes" - - theme_color: main: #007bff secondary: #6c757d @@ -470,7 +464,7 @@ theme_color: ## Copyright Settings -------------------------------------------------------------- cr_year: 2024 -cr_entity: "Amr" +cr_entity: *name cr_lisense: "MIT" ## Sitemap Settings -------------------------------------------------------------- diff --git a/script/zer0.sh b/script/zer0.sh old mode 100644 new mode 100755 index 5e6e3e4..d05fe18 --- a/script/zer0.sh +++ b/script/zer0.sh @@ -10,11 +10,16 @@ brew install git brew install gh brew install --cask docker brew install --cask visual-studio-code -# Or use the following to set the environment variables +# Or enter them in the terminal +echo "Please enter your GitHub username:" +read GHUSER +export GHUSER + +echo "Please enter your Git repository name:" +read GIT_REPO +export GIT_REPO export GITHOME=~/github -export GHUSER=bamr87 -export GIT_REPO=zer0-mistakes export ZREPO=$GITHOME/$GIT_REPO # Confirm the environment variables by echoing them and logging them to a file @@ -62,12 +67,12 @@ touch Gemfile echo 'source "https://rubygems.org"' >> Gemfile echo "gem 'github-pages' , '231'" >> Gemfile echo "gem 'jekyll' , '3.9.5'" >> Gemfile -echo "gem 'jekyll-theme-zer0' , '0.1.2'" >> Gemfile +echo "gem 'jekyll-theme-zer0'" >> Gemfile echo "group :jekyll_plugins do" >> Gemfile echo " gem 'jekyll-feed', \"~> 0.17\"" >> Gemfile echo " gem 'jekyll-sitemap' , \"~> 1.4.0\"" >> Gemfile echo " gem 'jekyll-seo-tag', \"~> 2.8.0\"" >> Gemfile -echo " gem 'jekyll-paginate', \"'~> 1.1'\"" >> Gemfile +echo " gem 'jekyll-paginate', \"~> 1.1\"" >> Gemfile echo "end" >> Gemfile # Download the _config.yml file from the jekyll-theme-zer0 repo diff --git a/zer0.md b/zer0.md index b0783e9..d864e92 100644 --- a/zer0.md +++ b/zer0.md @@ -133,11 +133,19 @@ brew install --cask visual-studio-code ### Or use default ```shell -# Or use the following to set the environment variables +# Or enter them in the terminal +echo "Please enter your GitHub username:" +read GHUSER +export GHUSER + +echo "Please enter your Git repository name:" +read GIT_REPO +export GIT_REPO +``` + +```shell export GITHOME=~/github -export GHUSER=bamr87 -export GIT_REPO=zer0-mistakes export ZREPO=$GITHOME/$GIT_REPO ``` @@ -228,14 +236,14 @@ touch Gemfile # Write the non-commented lines to the Gemfile echo 'source "https://rubygems.org"' >> Gemfile -echo "gem 'github-pages' , '231'" >> Gemfile -echo "gem 'jekyll' , '3.9.5'" >> Gemfile -echo "gem 'jekyll-theme-zer0' , '0.1.2'" >> Gemfile +echo "gem 'github-pages'" >> Gemfile +echo "gem 'jekyll-theme-zer0'" >> Gemfile echo "group :jekyll_plugins do" >> Gemfile +echo " gem 'jekyll-remote-theme', \"~> 0.4.3\"" >> Gemfile echo " gem 'jekyll-feed', \"~> 0.17\"" >> Gemfile echo " gem 'jekyll-sitemap' , \"~> 1.4.0\"" >> Gemfile echo " gem 'jekyll-seo-tag', \"~> 2.8.0\"" >> Gemfile -echo " gem 'jekyll-paginate', \"'~> 1.1'\"" >> Gemfile +echo " gem 'jekyll-paginate', \"~> 1.1\"" >> Gemfile echo "end" >> Gemfile ``` @@ -268,7 +276,7 @@ echo "RUN bundle update" >> Dockerfile echo "RUN bundle install" >> Dockerfile echo "RUN bundle clean --force" >> Dockerfile echo "EXPOSE 4000" >> Dockerfile -echo 'CMD ["bundle", "exec", "jekyll", "serve", "--host", "0.0.0.0"]' >> Dockerfile +echo 'CMD ["bundle", "exec", "jekyll", "serve", "--verbose", "--host", "0.0.0.0"]' >> Dockerfile ``` ```shell @@ -339,6 +347,6 @@ convert_md_to_files('zer0.md') ## Scripts -```shell +```bash {% include_relative script/zer0.sh %} ```