📜 ⬆️ ⬇️

How to promote the "Social Network Ark", if this is a fantastic trilogy

Three books with fiction and a site for reading is a project that has been going on for 2 years now.
And damn it, I like it. Now I will tell you how I made a site for reading my works.

Everyone should have a hobby that is not related to his professional activities. For the soul, for recreation, for self-realization, the development of their skills and the change of activity (which is the best rest). Through numerous experiments, I chose writing.

image
')
Having published the first book, I received quite a lot of good reviews. In this regard, I have a need to invent a convenient way to self-publish.



Why not a paper book?


At first there was a thought - send your book to 200 publishing houses in the country and wait for a response. After receiving the answer, it will be necessary to bring the book to mind for 6 months, with the help of editors and then another 6 months to wait for 2000 paper copies. Which without advertising (and it does not give for beginner writers) will be sold for a year. After thinking about this option and considering that I was not used to getting money for my hobby, I chose the option of promotion on the Internet. The Internet audience at the moment is more than a book-reading audience that is not connected to the network and goes to bookstores. You do not think, I am not against paper books, but as a method of promotion for a novice writer, a paper book is a very difficult and long way. (Recall how Lukyanenko started with free texts on the network, in .txt files.)

What should be the site to read?


To make the book available to anyone within two clicks, I created a website where you can read my books and download for free in all of the favorite formats for electronic readers.

It would seem that difficult in this site? But on the way of this fascinating quest, I was waiting for a few surprises.

Thinking up what my site will be like, I tried to transform into my own reader and take into account all my wishes:

Wishes of the modern reader to the site with books:
1) I want to be able to download a book in any format with a table of contents, for any reader (PDF, fb2, epub, mobi).
2) I want to be able to comment on the chapters in the book and share my impressions.
3) I want to be able to give my friends a short link or put Like on any social network if I like the book (for example, dictate the website address " 990990.ru " by phone).
4) When I'm at work, I can't get the reader, so I want access to reading on the site. The same item is valid if I do not have a reading room.
5) When reading on the site, I want the site to remember the reading position where I ended up. So that I can open the book at home and finish reading. And also, I hate registering. I want to log in through any of my social network.
6) I don’t want to see advertising and other distractions while reading. I want to be able to choose a background for reading.
7) I do not want to use the scroll to read such weighty volumes
8) Interrupting the reading, I do not want to then look for a place where I stopped the last time.
9) I want to learn about new books and chapters of unfinished books of the author, if I like his books.
10) Books should be interesting and written in easy language and preferably with the letters "e".

Considering that I also write books, after the site is ready, I took into account the requirements of the writer:

Requirements of a modern writer for his site:
1) It will be great if I can write directly on the site. I want to have a beautiful, convenient, minimalistic editor that does not distract me in Fullscreen mode. I want to have access here at any time, including from the iPad.
2) The site in two clicks should accept texts from my favorite program for writers Scrvener .
3) The editor should count the number of words in the chapter being created so that the chapters do not turn out to be very long and you can set a daily rate for yourself.
4) Publication of a new chapter, should be carried out in one click.
5) I want to know feedback from my readers.
6) I want to see the geographical position of my readers and statistics of downloads and scrolling of the book.
7) I want the appearance of the reading room, to have to read and not distract my readers from the plot.
8) I want to have a short link to distribute to my friends (for example, 990990.ru or wezel.ru )

Take care of the wheel or why a book with paging,
wins long text with scrolling:


Let it be selfish, but I chose the form of reading, which is convenient for me, when ahead, more than 2400 pages are waiting for me. I am a bright representative of the SMS generation, who likes to read, but which is distracting everything around. After the call of a friend, I should be able to quickly return my eyes to the line where they were before they were distracted.
I don’t like scrolling, because a long “footwoman” of a text can accidentally go to the very beginning and, then, it’s easier to start reading again than to look for a place where I’ve stopped. And reading is such a ritual act that does not tolerate any distractions.
It was possible to make a pagination “pagination” with page numbers at the bottom, but then, the reader will have to study this interface and understand the logic of rewinding. Getting into the small numbers downstairs is also not so easy when you empathize with the main characters, it is 3:00 in the morning and it’s time to sleep, but you want to finish reading.
Therefore, for other unconscious reasons, it was decided to be confused with the pagination output, so that everything was like a real book.

Table of contents of three books

In such a book, you need to make a table of contents with page numbers. For those who like to read the end and spoil their impression, this function is very good. Here you can switch between three works. At the end of the chapter, a small yellow leaflet shows the number of user comments on this chapter. You can click into it and add what has hurt you by reading.

White links, ordinary readers are not visible, with their help, I can open a chapter for editing or start writing a new chapter.

The page numbers are the hardest.


A book without page numbers is like a walk through a dark basement, when you do not know where the beginning and when the end is. Table of contents without page numbers is just a set of links.
The problem is one, how to break a long book into pages and still have the opportunity to update chapters (and the chapter may increase and decrease). Bookmate.com - solved this question by indicating the page number inside the chapter. Through numbering throughout the book is not. This is not our method. We have our own work and we have time to prepare a book for reading, by recalculating page numbers.

A simple algorithm that comes up with a long time:


How to break a long text into pages, I will try to describe in simple words, then I will give the script.
1. We take the source text of the book and insert “soft hyphens” there. We do this with the help of three lines of code (and the work of Sergey Kurakin ):
include 'hypher.php'; $hy_ru = new phpHypher('hyph_ru_RU.conf'); $text = $hy_ru->hyphenate($text,'UTF-8'); 

Without hyphenation, our text will look very sparse and non-compact. In the plugin settings, I set the hyphenation for only very long words, so the text looks neat and the hyphenation does not “part”. This code adds "& shy;" symbols inside the text. - which allow the browser to transfer words in these places.

2. We break a long book into chapters and enter in table 1_book:
1_book table
num are chapter numbers. book is the number of the book, while there are three of them. title - title of the chapter

3. By using a “long-thinking” script (I will describe the work just below), a simple table 1_books_p is created - in which the page number is indicated and from which symbol to which, cut the text of this chapter:
1_book_p table

So we create a table in which everything is calculated in advance. The user does not need to wait (and waste server resources) to calculate the pagination of the book. Everything is counted to us. This script is run only by the “writer” after he has changed the chapter. If the chapter is corrected by one, then you can only recalculate the numbering of this modified chapter, and the numbering of the following pages can be reduced or increased by the difference between what was and what has become. The work of the script rendering pages of one chapter takes 1 second.

Here is the script itself:
 <? include 'hypher_.php'; include 'pass_of_db.php'; $hy_ru = new phpHypher('hyph_ru_RU.conf'); $book = intval($HTTP_GET_VARS['book']); $glava = intval($HTTP_GET_VARS['glava']); if ($glava == '') $glava=0; $db = mysql_connect ($config[mysql_host], $config[mysql_user], $config[mysql_password]); mysql_query("SET NAMES utf8"); mysql_select_db($config[base_name],$db); if (!$db) { echo "   SQL :("; exit();} $sqlnews2="SELECT * FROM `1_books` WHERE book=$book AND num=$glava"; $result2 = mysql_query($sqlnews2); @$sql2 = mysql_fetch_array($result2); $text=$sql2['text']; //    $text = str_replace("\r",'</p><p>',$text); //  ,  " "    ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> </title> <script src="../src/js/jquery.js"></script> <script src="../src/js/cookie.js"></script> <link rel="stylesheet" href="css/style.css" type="text/css" media="screen"/> <script type="text/javascript"> function jsDoFirst() { //   $.ajaxSetup({async: false}); var maxgl; $('#load2').load("getinfo.php?book=<? echo $book; ?>&page=2",function() { maxgl = parseFloat( $('.maxglav').html() ); num=1; gl=<? echo $glava; ?>; if (gl==0) { gl_start = 0; gl_finish = maxgl; } else { $('#load2').load("getinfo.php?book=<? echo $book; ?>&glava="+(gl-1)+"&lastpage=1"); num = parseFloat( $('.lastpage').html() ); if(!num) num=0; num = num+1; gl_start=gl; gl_finish=gl; } for(glava=gl_start;glava<=gl_finish;glava++) { lnk = "getinfo.php?book=<? echo $book; ?>&p="+glava+"&start=0&limit=1200000&num=1&final=5"; $.getJSON( lnk ,function(text) { i=0; first=0; for(j=0;j<=20000;j++) { first=i; step=800; if ((text.length-1-first)<=0) step=0; for(i=first;i<=text.length-1;i+=2) { if(j==0) pref="<h1></h1>"; else pref=""; $('#b-load2').html(pref+'<p>'+text.substr(first,i-first)); h = $('#b-load2').height(); if(h>=590) { i=i-1; newtext = text.substr(first,i-first); vv=razvedka(text,first,i); i=vv+first; newtext = text.substr(first,vv); next=first+vv; $('#load2').html($('#load2').html()+'<font size=-2em>start='+first+' to='+next+' num='+num+'</font>'+'<hr>'+newtext); lnk = "getinfo.php?writepage="+num+"&start="+first+"&to="+next+"&book=<? echo $book; ?>&glava="+glava; $('#load3').load(lnk); console.log(lnk); num=num+1; flag=1; break; } } if (flag==0) { next=text.length+1; lnk = "getinfo.php?writepage="+num+"&start="+first+"&to="+next+"&book=<? echo $book; ?>&glava="+glava; $('#load3').load(lnk); num=num+1; console.log('fin='+lnk); break; } flag=0; } }); } if (gl!=0) { lnk="getinfo.php?book=<? echo $book; ?>&glava="+gl+"&getback=1"; $('#load2').load(lnk); self.close(); } }); } function razvedka(text,first,i) { /*     :     ,  </p>  </p>,   </p>    ( .   <p>)    ,          <p2>.    ,      ,           . */ newtext = text.substr(first,i-first); space=newtext.lastIndexOf(" "); addspace=1; parag=newtext.lastIndexOf("</p>"); addparag=4; if ((space-parag)<5) {vv=parag; add=addparag; } else {vv=space; add=addspace; } return vv+add; } </script> <script type="text/javascript"> $(document).ready(jsDoFirst); </script> </head> <body> <div class="book_wrapper"> <div class="animate2"> <div id="b-load2" style="width:365px;padding-top:20px"></div> </div> </div> <div id="load2" style="background-color:white"></div> <div id="load3"></div> </body> </html> 


I am not proud of my PHP and Javascript coding style, so please do not beat them with a stick. The essence of my description relates more to the algorithm for determining the starting and ending point of breaking the chapter, so that the text is enough to fit onto the page and smoothly continue the previous text.

The essence of the script, which is higher in the fact that it takes 800 characters from the chapter and displays it in a div, which exactly repeats the page of the book on the site itself. If the height of this div does not exceed 590 pixels, 2 characters are added to the text and its new height is measured. As soon as we increased the text so much that it began to crawl out of 590 pixels, we stop and, using the Razvedka function, look for the closest space or character of the end of a paragraph. So we find a place where we will break this chapter. “Getinfo.php? Writepage” - writes the calculated values ​​to the base for “1_books_p”.

It turns out that all calculations of page numbers occur on my computer in my browser. I could not do it on the server. To predict how many characters need to be placed on the page so that it is displayed correctly - you need to know the width of characters, make hyphens, take into account the indentation between paragraphs. The algorithm is not comprehensible for my amateur brain.

How to make page turning animation:


At first, I thought that I would spend several days on this part of the project, but, miraculously, I managed to implement everything in 30 minutes. It turned out that flipping is an animation of two sides of one sheet. One div should be reduced in width to zero, and the other increased to the width of the sheet. Still surprised by the simplicity of the solution. For this, I love jQuery.
 function rotate() { ease = 'easeInQuad'; //easing -   tim = 700; maxpages=parseFloat($('.maxpages').html()); //  ,     $('.animate3').show(); //  div    $('.animate3').css("left",105).css("width",0); //         413  $('.animate3').stop().animate({"left": "523","width":"413"},tim,ease, function() { $('.b-load4').html($('.b-load3').html()); // ,        $('.num4').html($('.num3').html()); $('.animate3').css("left",105).css("width",0).hide(); $('.animate3').css("-webkit-box-shadow",""); if ( $('.b-load3 #end').html() != null ) //    ,   { update_comment(); $('.clip_right').fadeIn(600); $('.comments_right').fadeIn(600); } else { $('.clip_right').fadeOut(50); $('.comments_right').fadeOut(50); } if ( $('.b-load2 #end').html() != null ) { update_comment(); $('.clip_left').fadeIn(600); $('.comments_left').fadeIn(600); } else { $('.clip_left').fadeOut(50); $('.comments_left').fadeOut(50); } afterrotate(); }); $('.animate1').css("width",413).show(); //     (    0) $('.b-load1').show(); $('.animate1').stop().animate({"width":"0"},tim,ease, function() { $('.b-load1').html($('.b-load2').html()) $('.num1').html($('.num2').html()) $('.animate1').show(); $('.animate1').css("width",413); }); } 


The whole animation consists in the simultaneous movement of two divs, one of which is the old page and the other one is new. It looks beautiful, but it’s hard to understand if you don’t know how to read the code. I will not tell you how to bind paging per click on the page or pressing the arrow keys. This you can see in the script on the site itself.

How to log in to the site in one second:


Authorization for such a site is needed for one simple but necessary thing. The reader does not have to remember which page he opened last time. You can’t hang a bookmark on the monitor, but there are three books and you need to remember the position in each of them. I used a great Loginza.ru authorization service.

Login with Loginza

The desired button in the middle. Who wants to click and try, as easy to log in with: vkontakte, odnoklassniki, mail, gmail, facebook and so on ...
The Like buttons from Yandex for all social networks are also located here. Counter LIKE'ov ("link to the book placed 22 readers") works by intercepting clicks using javascript.

You can also select a background for reading by clicking on the "change background" button. Here you can choose one of three books and even click on the link " download book ".

Count everyone who downloaded PDF, epub, mobi, fb2:


I do not need to monetize this project, so the download of files is free.
The page looks like this:

Download the book Ark social network

It would seem nothing complicated. But how to make a counter to download, if the links should look fair, like this: " wezel.ru/book/download/kovcheg-1.fb2 "?

Even from my experience with w3bsit3-dns.com, I remember how often links pull to my website and links like: “download.php? File = kovcheg-1.fb2” they really don't like.

This is solved by a simple mod_rewrite:
 RewriteEngine On RewriteRule kovcheg-1.(.+..+)$ getfile.php?name=kovcheg-1&ext=$1 RewriteRule kovcheg-2.(.+..+)$ getfile.php?name=kovcheg-2&ext=$1 RewriteRule kovcheg-3.(.+..+)$ getfile.php?name=kovcheg-3&ext=$1 


At the same time, the getfile.php script is here:
 <? header("Content-type: application/x-gzip"); $name = $HTTP_GET_VARS['name']; $ext = $HTTP_GET_VARS['ext']; $filename = $name.'.'.$ext; if (!stristr($filename,'kovcheg')) exit; if (stristr($filename,'..')) exit; include "../pass_of_db.php"; $db = mysql_connect ($config[mysql_host], $config[mysql_user], $config[mysql_password]); mysql_query("SET NAMES utf8"); mysql_select_db($config[base_name],$db); if (!$db) { echo "   SQL :("; exit();} $sqlnews2="INSERT `1_books_log` (`id`, `identity`, `book`, `page`, `date`, `file`) VALUES (NULL, '".$_SERVER['REMOTE_ADDR'].' : '.$HTTP_COOKIE_VARS['identity']."', '-2', '0', NOW(),'".$filename."')"; $result2 = mysql_query($sqlnews2); $fd = fopen ($filename, "r"); $code = fread ($fd, filesize($filename)); fclose ($fd); switch ($ext) { case 'fb2' : echo $code; break; case 'epub' : echo $code; break; case 'pdf' : echo $code; break; case 'mobi' : echo $code; break; } ?> 


So you can collect statistics for readers who download files, even if the link is on another site.

What does my workplace look like?


I write books here:
Edit the book social network Ark
Nothing superfluous and when you press F11, you can begin to build crystal locks of the plot in your head. Nothing distracts. Chrome checks the literacy of the text during input, and the corrector hired by me, after I finish writing each book. I have a big trouble with commas, so without a corrector it would be more difficult.
In the title of the browser tab, I count the number of words in the edited chapter, this provides an approximately equal number of words in the chapter (approximately 2000).

At the end of the story, comments always go:



Comments on the book Ark social network

Comments are what distinguishes the Internet from TV, radio, books, music and movies.
To make a modern book without comments, my hand would not have risen. The design is familiar to most Internet users, which makes it easier for others to read and write. You can plyusovat and minusovat comments. He wrote the scripts himself, nothing complicated about it.

What is your book about? - you ask


Three books and they are different.
1 book: This is a fantastic trilogy about how the main character enters Moscow of the future. 1500 years have passed and the 36th century has come. Describes with all the details of their gadgets, politics, nature, psychology. Will the “Ark social network” be able to save humanity? The beginning may seem boring to someone, so the impatient can start with chapter 18. At the end of the book, many have a break of patterns and thoughtfulness for several weeks.

2 book: Tells about America of our time. The nature of various human addictions and the methods of their use are described. You look at the world device that surrounds us from an unexpected angle. In the story, we come to a new theory of world conspiracy.

Book 3: The protagonist and 200,000 people fall on another planet. She is inhabited by unusual white angels who have dreams that they do not remember. The main question of the novel, how two civilizations get along with each other.

Better than me, readers will tell about the book.

Enjoy your reading .

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


All Articles