code

From IndieWeb

code in the context of the indieweb, refers to source code, code files, typically in a revision control system, like Git, hosted on an indieweb site. Code is also often hosted on the GitHub silo.

Why

Hosting your own code lets you share your code with URLs you control on your own domain.

IndieWeb Examples

Christian Weiske

Christian Weiske uses GitWeb to post his source code at http://git.cweiske.de/ since 2007

Mirror setup

On indieweb server:

$ git init --bare project.git
$ cd project.git
$ git remote add github git@github.com:cweiske/project.git
$ git config remote.github.mirror true

On Github, add the mirror user as collaborator for the project. Now test it:

$ cd /path/to/project.git
$ git push github

If that works, the post-receive hook can be setup:

$ printf '#!/bin/sh\ngit push --quiet github\n' > hooks/post-receive
$ chmod +x hooks/post-receive

This force-pushes the code got github, which means any changes on github that are not on my server get overwritten. Thus cannot use the merge button on github, but have to merge manually.

Tantek

Tantek Γ‡elik manually hosts the latest live version of CASSIS at: http://tantek.com/cassis.js (without revision control) and manually POSSEs it to https://github.com/tantek/cassis/blob/master/cassis.js (with revision history) since YYYY-MM-DD.

Aaron Parecki

Aaron Parecki uses a Gogs instance to host some private repositories on aaronparecki.com since 2016-02-13. Previously, he ran an instance of Gitlab but migrated away from it after some time.

  • Some of these projects are shared with a few other people who are able to log in and contribute.
  • All Aaron's public code is on GitHub, because it makes it easier to share and get contributions from others.

Ray Schulz

Ray Schulz uses cgit for the web interface and gitolite for the backend of http://git.rascul.io/ since YYYY-MM-DD.

Dmitri Shuralyov

Dmitri Shuralyov hosts Go packages created after 2017-09-13 on his personal website. His website is a custom Go package host, written in Go and fully open-source, implementing features such as git repository serving, issue tracking, notifications, history viewing, etc. As of 2021-12-27, it also supports performing code review on changes before submitting them.

Software

Software you can use to host your own Git repository:

Code Snippet

Similar to source code hosting, but simpler and often used for examples rather than actual running code, code snippet hosting is a way of sharing bits of code from your site instead of an entire file.

Services like pastebin or gist allow people to quickly post snippets of code without organizing into a repository or project.

IndieWeb Examples

cweiske

Christian Weiske uses phorkie to self-host code snippets on a separate subdomain.

aaronpk

Aaron Parecki posts code snippets to his site since 2018-01-06

pstuifzand

Peter Stuifzand posts code snippets to his site since 2018-03-21

Source Code Embedding

Some blog/CMS systems do not support syntax highlighting of source code, so users embed highlighted code from pastebins like gist.github.com or phorkie.

Pastebin sites often provide JavaScript embed code to make it as easy as possible to embed code in own HTML documents.

Differences between pastebin views and embeds

It can be necessary to have different markup for embedded source code and the source code display in the pastebin tool.


Pastebin software

Use case: Work with and modify the paste. Single files have edit and "raw" view buttons, maybe more. File names are important and are shown before the code itself.

Example: http://p.cweiske.de/160


Embeds

Use case: Show a bit of colorful source code, but don't get in the way. No edit buttons. File names are unimportant, so show them after the code.

Example: http://cweiske.de/tagebuch/phorkie-0.5.0.htm#embed

Brainstorming

Cross-site fork buttons

Cweiske.de 13:00, 20 March 2014 (PDT)

Instead of the usual "fork me on github" buttons, projects should use a more general "fork me" button.

It should fork the code onto the user's preferred git server instead of a silo. The button could either work like subtome, showing a list of services that support remote forking, or simply use a custom protocol like "web+fork://" that web sites can register itself as HTML5 protocol handler.

The URL syntax could be like the feed uri syntax:

web+fork:https://example.org/project.htm

The linked URL could be the homepage of the project, with embedded rel-vcs links that provide the git:// or http:// URLs to the git repository. Or it could be the git repository URL itself. phorkie supports remote forking via rel-vcs since version 0.3.1. See the blog post for a description of the process.

Host code docs versions

Brainstorming: host code, with documentation, ideas behind it, versions over time: https://twitter.com/AndreJaenisch/status/1331900348752138240

  • "Good to know!

    Look, I like to host code I write on my site (eventually).
    I would like to document the process of making and my ideas behind it.
    The only way I can do that in CodePen is through comments (or a section in the HTML).
    Then, you cannot see the progress over time." @AndreJaenisch November 26, 2020

See Also