~jameschip/clogs

80733d39ab12c26f5acbabfda7178d1c7560c7c3 — James Henderson 4 months ago master
Add clog project files
8 files changed, 244 insertions(+), 0 deletions(-)

A LICENSE
A README.md
A clog/1
A clog/index
A clog/new.sh
A clogs.sh
A index.html
A style.css
A  => LICENSE +15 -0
@@ 1,15 @@
Copyright © [year] [copyright holders]

This is anti-capitalist software, released for free use by individuals and organizations that do not operate by capitalist principles. 

Permission is hereby granted, free of charge, to any person or organization (the "User") obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

1. The above copyright notice and this permission notice shall be included in all copies of the Software.
2. The User is one of the following:
a. An individual person
b. An organization of people that does not seek profit
c. An organization of people that seeks shared profit for all its members and does not exploit the labor of non-members
3. If the User is an organization with owners, then all owners are workers and all workers are owners with equal share.
4. If the User is an organization, then the User is not law enforcement or military, or working under either.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

A  => README.md +43 -0
@@ 1,43 @@
# clog
A blog that is read with curl (curl + blog = clog)!

# The format of a clog (a rough draft).

A clog is the smallest possible instance of a blog I could imagine and has a simple structure. All you need is a folder called ```clog``` in the root of your website that contains a file called ```index```. The only other file I have included in the spec at this point is ```links``` and is optional. Posts in your clog are just numbered files that contain the text for the post. None of these files have an file extension.  
  
Thats all there is to it.  
  
If you want to get started with your own blog you can lone the ```clog``` directory in this repo to the root of your website and look in the post for further  instruction on what to do.
  
```
    clog/
     |__ index <- This i the home page of your clog
     |__ links <- for linking to other clogs and such
     |__ 1 <- a post
     |__ 2 <- another post
```

## The index file.

This is my current suggested syntax for the index page.  
  
  
* it should have one line that reads ```Posts:\n```, every line after that is a 'link' to a post.
* A link to a post has the format ```<POST_ID> : Post title```
  
Everything before the Posts: tag is just header text to introduce your clog.
  
As you add more clog posts add them to the bottom of your index file, this way when a reader gets your index the most recent posts will be the ones they see first.

## The new.sh

While not necessary the new.sh can be run to easily create the template for a new post for you! It counts how many files there are in the directory and then creates a new post with that number as an ID and adds the appropriate line to the end of the index file for you!

## The clogs.sh

This is a really simple clog reading client in a bash script! You can check to see if a website has a clog by typing in its url, you dont even need to put the ```/clog/index``` on the end as it does it for you. Copy this somewhere and pop an alias in your .bashrc to run it and you have an almost seamless way of reading clogs in your terminal.

## Why?

The web is getting a bit fat and bandwidth is getting used up at an alarming rate. Blog posts about bloat problems on the web are themselves running into multiple megabytes in size just to present you with 500 or so words of content. This is obscene! A blog, in its most distilled form is a text document. The clog was a simple experiment in stripping the blog back to its smallest possible size. Due to the nature of the clog it is also naturally accessible to any maching that can run curl (most machines) including very old machines that would struggle now just displaying an average post from medium. You can read your clog from a computer that doesnt even have a GUI!  
  

A  => clog/1 +18 -0
@@ 1,18 @@
Wed 19 Aug 19:19:59 BST 2020
So what is a clog?

A clog is a tiny blog that is meant to be read in the terminal using the 
curl command. If you want to start your own clog simplyfollow these steps:

1) Copy this clog directory to the root of your website.
2) Delete this post (remove the line in index for it too).
3) run new.sh to create a new post.

Thats it, your clog will be viewable at:

	curl -s www.yourwebsite.com/clog/index

You can add any introduction text you want before the "Posts:" line in index.
Everythin after "Posts:" should be a line referencing a post.

Enjoy!

A  => clog/index +8 -0
@@ 1,8 @@
The title of your clog!

	Useage: curl -s www.yourwebsite.com/clog/index
	
You can put an introduction to your clog here if you like.

Posts:
	1:	So what is a clog?

A  => clog/new.sh +19 -0
@@ 1,19 @@
#!/bin/bash

DT=$(date)
IFS=''
INDEX_FILE=index

echo -n "Title of blog post to create: "
read TITLE

FILE_COUNT=$(( $(ls | grep -e '[0-9+]' | wc -l) + 1 ))

printf "Entry created : %s\n" $FILE_COUNT

touch $FILE_COUNT

printf "\e[2m%s\e[0m\n" $DT >> $FILE_COUNT
printf "\e[4m%s\e[0m\n\n" $TITLE >> $FILE_COUNT
printf "\t%s:\t%s\n" $FILE_COUNT $TITLE >> index


A  => clogs.sh +95 -0
@@ 1,95 @@
#!/bin/bash

BOOKMARK_FILE=~/.clog_bookmarks
BASE_URL=""
CLOG_URL=""

print_help () {
	echo "g - Goto clog. (you dont need to put the /clog/index on the end of the url, this command can nbe used to check if a website has an ecisting clog)"
        echo "p - goto post while at clog"
        echo "i - show index of current clog"
        echo "h - this help text"
	echo "B - Add this clog to bookmarks"
	echo "b - list bookmarks"
	echo "G - goto bookmark"
        echo "q - quit"
	echo ""
}

check_url () {
	if curl --output /dev/null --silent --fail -L -r 0-0 "$CLOG_URL"; then
		clear
		curl -Ls $CLOG_URL
		echo ""
		echo ""
	else
		echo "No clog at $CLOG_URL"
		CLOG_URL=""
	fi
}

print_bookmarks () {
	clear
	n=1
	while read line;
	do
		echo "$n : $line"
		n=$((n+1))
	done < $BOOKMARK_FILE
	echo ""
}

clear
echo "Welcome to the clog reader, making clogs a tiny bit easier to read"
echo ""
print_help

while :
do
	read -p ": " -s -n1
	echo ""
	case $REPLY in
	'q')
		exit 0
		;;
	'g')
		read -p "Check for clog at: "
		BASE_URL=$REPLY
		CLOG_URL="${REPLY}/clog/index"
		check_url
		;;
	'G')
		read -p "Goto bookmark: "
		CLOG_URL=$(sed "${REPLY}q;d" $BOOKMARK_FILE)
		BASE_URL=$(sed "${REPLY}q;d" $BOOKMARK_FILE | grep -P -o -m 1 "[^/]*" | head -1)
		check_url
		;;
	'p')
		read -p "Goto post: "
		CLOG_URL="${BASE_URL}/clog/${REPLY}"
		check_url
		;;
	'i')
		CLOG_URL="${BASE_URL}/clog/index"
		check_url
		;;
	'B')
		read -n1 -p "Add ${CLOG_URL} to bookmarks? y/n"
		case $REPLY in 
			'y')
				echo $CLOG_URL >> ~/.clog_bookmarks
				;;
			*)
				;;
		esac
		echo ""
		;;
	'b')
		print_bookmarks
		;;
	'h')
		print_help
		;;

	esac
done

A  => index.html +41 -0
@@ 1,41 @@

<!DOCTYPE html>

<head>
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>
<br>
<br>
<br>
<br>
<h1>Clogs</h1>
<pre> curl -s CLOG_ADDRESS_HERE </pre>
www.jameschip.io/clog/index<br>
leetusman.com/clog/index<br>
francesconegriolli.com/clog/index<br>
	
<!-- ^ADD YOUR SITE ABOVE THIS DONT FORGET THE <br> on the end!^ -->
<br><br>
<hr>
<h1>What?</h1>
A clog is a tiny blog that is read in the terminal using curl (curl + blog = clog).<br> 
You can read one by adding one of the addresses above to the end of the command "curl -s" <br>
<br>

<h1>Can I have a clog?</h1>
YES! <a href="https://github.com/jameschip/clogs">Follw the instructions here!</a>

<h1>Can I get my clog listed here? </h1>

You can. <br>
Your clog must reference back to being a member of this clogring in your index header.<br>
No clogs that contain racist, sexist, ableist or otherwise discriminatory or illegal content will be accepted.<br>
You can add you page by putting it in the list of pages ^up there^ and opening a pull request!

<h1>Why?</h1>
Why not?

</body>

A  => style.css +5 -0
@@ 1,5 @@

body {
	text-align: center;
	font-family: Arial, Helvetica, sans-serif;
}
\ No newline at end of file