📜 ⬆️ ⬇️

Internet on Magnets 2 - Hypertext

It is time to unleash the hypertext and expand the possibilities of its distribution not only in the classical client-server way, but also in peer-to-peer networks. In order to be perceived in full by small efforts, the webmaster will have to try. To do this, you need the resources needed for the correct display to pack in HTML. If everything is clear with scripts and styles - their text can be inserted with the contents of the corresponding script and style tags, pre-processing is already necessary for images.



Image processing


The image must be saved in JPEG with progressive mode enabled, and the compression level must be adjusted so that the image looks good not only when it is fully loaded, but also quite acceptable in the truncated version for IE (32768 characters in the data url). For this, for example, I used IrfanView. When saving the image, we tick the progressive mode (Save as progressive JPG). Additionally, put a checkbox on "Try to save with original JPG quality". I took the rest of everything: we don’t need extra data in the file.


Use Data Url


Now base64 encode the resulting image. The MIME Tools plugin for notepad ++ does an excellent job with this.


  1. Open the image file in Notepad ++
  2. Edit -> Select All
  3. MIME Tools -> Base64 encode
  4. We add the result to the beginning of the "data: image / jpeg; base64,"
  5. Copy and paste into HTML document

<img src="data:image/jpeg;base64,/9j/4AAQS..." alt="" /> 

Other image formats should be tried in the framework of IE, that is, at 21,830 bytes if base64 is used. Also, do not forget to change the mime type image / jpeg to the appropriate file type.


Hypertext File Name and External Resources


Requirements:


  1. Uniqueness of the name - The file name must be chosen taking into account the fact that the file may be in one directory with many others. To do this, you can add the creation time or crc file to the name.
  2. Your unique prefix - the file name is desirable to start with the name of the author (or other key that you will use for all created pages). Thus, it will be convenient to group the files by author.

 03.04.2012 13:04 947 346 archimeta-ru-kryg-2012-04-03-13-04.mp4 03.04.2012 13:05 1 792 810 archimeta-ru-kryg-2012-04-03-13-04.ogv 03.04.2012 13:05 1 107 873 archimeta-ru-kryg-2012-04-03-13-04.webm 03.04.2012 14:28 243 432 ivan386-p2p-html-2012-04-03-13-04.html 

External resources


Unfortunately, not everything can be packaged in one file. With a significant html size there may be problems with the performance of the browser. So video and audio podcasts will have to be kept (and downloaded accordingly) separately. Especially for full compatibility requires 3 types of video and 3 types of audio (you can also of course wav if desired).


We have all the necessary versions of video and audio, run them through rhash and get a combined magnet for each.


For example, I wrote the following cmd file:


 %~d0 cd %~p0 rhash --torrent -p "%%f#magnet:?xt=urn:ed2k:%%e&xl=%%s&dn=%%u&xt=urn:tree:tiger:%%t&xt=urn:btih:%%{btih}" %1 %2 %3 %4 %5 %6 %7 %8 %9 | clip 

Combined magnet straight to the clipboard and torrent file next. True clip with whists appeared, so for the good old HP you need a separate utility. Well, or the good old way:


 rhash --torrent -p "%%f#magnet:?xt=urn:ed2k:%%e&xl=%%s&dn=%%u&xt=urn:tree:tiger:%%t&xt=urn:btih:%%{btih}" %1 %2 %3 %4 %5 %6 %7 %8 %9 > temp.txt notepad temp.txt 

 archimeta-ru-kryg-2012-04-03-13-04.mp4#magnet:?xt=urn:ed2k:e803fe1127ad3cd20bc335bbd17c6c8b&xl=947346&dn=archimeta-ru-kryg-2012-04-03-13-04.mp4&xt=urn:tree:tiger:tm6z5ohogst2qsmbq2awl7dz4niz2dokzawz5jq&xt=urn:btih:884162be8064f3bf10e524a0b03fc0e3e796c56f 

Also, Shareaza can make magnets on a template (if the file is already shared it will not have to be processed a second time).


It would be possible to separately give a magnet to the file, but it is better to separate them with a script. So the magnet is tightly bound to the resource, and it is clear that this is one file. This will further automate the boot process. You can also specify a direct link to the file on the server in the magnet (see Web link to the file (as, xs) ).


Most likely, having opened the page with the video for the first time, the video file itself will not yet lie on the disk, and it only has to be downloaded. Therefore, in the preload property of the video tag, set to none, and in the poster property, insert the data url with a frame from the video or any other content to fill the empty space.


Well, actually, in the source tags we write our combined magnets in the order mp4, webm, ogv.


 <video id="movie" width="640" height="480" preload="none" controls="controls" poster="data:image/jpeg;base64,/9j/4AAQSkZJRgA..."> <source src="archimeta-ru-kryg-2012-04-03-13-04.mp4#magnet:?xt=urn:ed2k:e803fe1127ad3cd20bc335bbd17c6c8b&xl=947346&dn=archimeta-ru-kryg-2012-04-03-13-04.mp4&xt=urn:tree:tiger:tm6z5ohogst2qsmbq2awl7dz4niz2dokzawz5jq&xt=urn:btih:884162be8064f3bf10e524a0b03fc0e3e796c56f&as=http://derevo.archimeta.ru/video/kryg/kryg.mp4" /> <source src="archimeta-ru-kryg-2012-04-03-13-04.webm#magnet:?xt=urn:ed2k:bba8e1f790f667ac53403cd5d8797edb&xl=1107873&dn=archimeta-ru-kryg-2012-04-03-13-04.webm&xt=urn:tree:tiger:ffmycgrdaxsnvtg4oqdpg5nmesjvlo5xkgg3qdq&xt=urn:btih:870d0cf99445258193947d055674efc5fe2bbb67&as=http://derevo.archimeta.ru/video/kryg/kryg.webm" type='video/webm; codecs="vp8, vorbis"' /> <source src="archimeta-ru-kryg-2012-04-03-13-04.ogv#magnet:?xt=urn:ed2k:a44f88787b879fa3b0b6493509e989f9&xl=1792810&dn=archimeta-ru-kryg-2012-04-03-13-04.ogv&xt=urn:tree:tiger:5tvhqhlv4rj7mss4kzwkmc4ujn43uz26vlbdhjq&xt=urn:btih:787ef1f3dedc36dfbf20f0d1e946be5b4b1ee580&as=http://derevo.archimeta.ru/video/kryg/kryg.ogv" type='video/ogg; codecs="theora, vorbis"' /> </video> 

When our p2p webpage is ready, we make a combined magnet on it in a similar way and publish it. Naturally, if you publish it on an external resource, it only makes sense to use a magnet.


Do not forget that in order to be able to get your page and resources, it must be shared in p2p networks. At the moment, the Shareaza client is well suited for this. supports multiple networks.


Well, I think it's time to finish the second part of the article, otherwise I have already kept it on my disk for so long.


This article with examples

Magnet Internet 1 - Magnet
Internet on Magnets 2 - Hypertext
Internet Magnets 3 - P2P Website and Forum
Internet on magnets 4 - Divide the magnet into pieces
Magnet Internet 5 - Lighthouses and Messages (Personal, Public and Updates)

')

Source: https://habr.com/ru/post/141307/


All Articles