Skip to content

nkpro2000sr/Updatable-PermaLink

Repository files navigation

solution

this is done by creating Github Repo with GitHub Pages activated.
here the permanent url is github-pages url of content in repo.
which can be updated at any time.

Primary Step

create repository with GitHub Pages turned on

#] For Dynamic Embedded Gist

create a reverse_proxy_script.md which has url of gist you want to show.

var url = "gist_url"
document.write('<script src="'.concat(url,'"></script>'))

now <script src="url_to_your_github_pages/reverse-proxy-script.md"></script> is the permanent url. 😉

'url_to_your_github_pages' is like 'https://UserName.github.io/github-pages-activated-repo-name'.

Sample:

see this demo.html.

#] For Dynamic File Link

Upload a file you want to create link for in your github pages activated repo.

now url_to_your_github_pages/Filename.ext is the link to the file.
you can also place file in directories inside repo, for this just replace Filename by File path in url.

Exapmple:
  1. Sample Image 1: https://nkpro2000sr.github.io/Updatable-PermaLink/SampleImage.png
  2. Sample Image 2: https://nkpro2000sr.github.io/Updatable-PermaLink/SampleImage
  3. Sample PDF 1: https://nkpro2000sr.github.io/Updatable-PermaLink/SamplePdf.pdf
  4. Sample PDF 2: https://nkpro2000sr.github.io/Updatable-PermaLink/SamplePdf
  5. Sample File 1: https://nkpro2000sr.github.io/Updatable-PermaLink/Sample.zip
  6. Sample File 2: https://nkpro2000sr.github.io/Updatable-PermaLink/SampleFile

In these examples, 1,3,5 have extension and 2,4,6 don't have extension.
GitHub Pages serves these with different header based on extension. If no extension provided it is considered same as only downloadable file.
In above example:

  1. SampleImage1 is shown in page. since it has image file extension.

GitHub Pages don't shows images > 5MB. it simply asks to downloads it. (see this for reason)

  1. SampleImage2 is simply asks to download. since it don't has extension.
  2. SamplePDF1 is shown in browser. since it has pdf extension.
  3. SamplePDF2 is simply asks to download. since it don't has extension.
  4. SampleFile1 is also asks to download. since zip file format is not viewed in browser.
  5. SampleFile2 is simply asks to download. since it don't has extension.

> We can also force url with showable extension to simply asks to download by a simple trick.

  1. Create an html file. For example 'SampleImage.png.html'
<a id="Download" href="SampleImage.png" download></a>
<script type="text/javascript">
    (function () {
      document.getElementById("Download").click();
    })();
</script>
  1. now https://nkpro2000sr.github.io/Updatable-PermaLink/SampleImage.png.html will only download image instead of showing like example_1.

> We can also force url without showable extension to show.

  1. Create an html file. For example 'SampleImage.html'
<img src="SampleImage" style="max-width:100%;height:auto;">
  1. now https://nkpro2000sr.github.io/Updatable-PermaLink/SampleImage.html will only shows image instead of downloading like example_2.

we can also make PDF shown in browser instead of downloading by this method.

Note:

The files whose filename begins with underscore '_' will not be accessed via url.
Example '_nk.png' will not be viewed using https://nkpro2000sr.github.io/Updatable-PermaLink/_nk.png.
But can be viewed through:

  1. Github https://github.com/nkpro2000sr/Updatable-PermaLink/blob/master/_nk.png
  2. Raw Github Content https://raw.githubusercontent.com/nkpro2000sr/Updatable-PermaLink/master/_nk.png.

only if it is a public repo.

About

to create permanent link that will forever include all the changes, and uptodate.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages