In the collection of scripts for the
HabrAjax 0.79 site,
it became possible to collapse annotations in the ribbon for authors specified by the reader and if the specified lines coincide (you can call the folding lines). For example, if the reader wants to highlight the works of a certain author, showing only the title of the article in any tape (main, favorites, search), he enters the author’s name into a special list and includes a folding setting. Or - collapse annotations, if in the title or in the text of the annotation there is a certain sequence of characters (not words, but symbols). The second filter works on regular expressions, so the reader actually sets not the strings separated by commas, but the bodies of regular expressions, ignoring the size of the letters, but taking into account all the characters and spaces.
On this fact, you can build filters that take into account the declination of words. For example, if there is a desire to roll up announcements using words from the “motivation” group (for example), you need to write the following filter string: “motivational, motive” (without a space) or add it with similar roots. The filter will search for regular text / motivac / im, / motive / im in each annotation text (“im” specifiers mean: “search ignore case, for all lines.” If found, the body of the regular expression (all found) is added to the signature therefore the reader will know for what reason the annotation is folded.
All folding takes place to the size of the header. Content and tags are collapsed, title and caption are visible. Full list of minimization settings (everything is disabled):
1. Search by authors from the list of authors.
2. Search by lines - regular expressions - in the texts of annotations and in their titles (ignoring case of letters).
3. Search for the names of blogs, considering them as the beginning of the annotation (Use the "^" symbol at the beginning).
4. Collapse blogs companies.
5. Collapse podcasts (includes several blogs).
6. Mode of incomplete folding "Forced cat" - collapses the content to a height of 240 pixels and makes a number of other sealing actions.
Example of setting up the line:
An example of the result of the specified filter (it is clear that the words "Sean" and "Junio" found in the filter were found):
Limitations:
Of course, when writing, it is necessary to take into account special symbols of expressions and to screen them with an inverse slant. Particular attention should be paid to the points (write as "\."), Because in reg.expressions they mean "any character". And do not use commas, because they are list separators. Full set of special characters: "* /. + $ ^? \ () [] {}". Read more about reg expressions
here .
')
In the list of authors, regular expressions are not used, case is taken into account, extreme spaces are ignored.
Now there is a similar filter
HabraTopicFilter , from crea7or, which does not have a search by rows, but collapses annotations by authors. In addition, it works by blog names (collapse blogs with the specified names and by companies in general (separate setting). There is no possibility to view and edit text lists. It would not have been difficult to write the third setting in HabrAjax - collapse by blog names. But not to produce the number of settings, another solution was invented - attach the blog name to the beginning of the annotation text (so you can search by "^ blog_name"). In the HabrAjax script, there are also 2 special filter settings — on companies' blogs in general and on the podcast am
The site has a view of the tape without any articles of companies ("Thematic"). But the advantageous difference between the “Collapse companies' blogs” setting is that it leaves the names of companies and articles (in the general tape) and a full view on the click on the name. If you need to minimize several specific companies, you should start the filter string by company name with the symbol "^". For example, "^ Personal blogs".
Forced cat
Finally, in the settings of HabrAjax there
is an incomplete folding mode , the so-called “Forced Cat”. It solves several other related problems and also limits the visible amount of information in the tape.
A complete list of Forced Kata strategies and rules:
1. Limits the maximum height of the annotation (244 pixels for ZenComment styles and 344 for classics).
2. Reduces the size of pictures (maximum 240 by 120 or 340 by 170).
3. Replaces videos reduced links with pictures.
4. Moves low-lying images to the top to wrap text, marking the starting positions of the images.
5. Removes vertical spaces, replacing small gray blocks.
6. Reduces leading by 10%, if it avoids the scroll bar.
7. The problem of a large number of tags is solved, as in the example:
Examples of the work of forced kata. Classic (decreased pictures and video):
Example in
ZenComment (on another annotation: pictures, video have decreased, vertical gaps are compressed, picture 1 is moved up, scrolling appears; height - 244 pixels):
What is the 6th strategy like? (A strategy, not a rule, because each point may require a sequence of measurements and actions distributed over time.) The difference in this screenshot is clearly visible. Left - without it, right - with the application. The scrollbar disappears, which was practically useless and made it difficult to view the last line of text. Cost - a slight text compression. This is practiced in newspapers when it is necessary to adjust the height of the column. The probability of occurrence is less than 10%. (If the code uncomments' sett-topic2'.wcl, in the console you can see to which topics the rule is applied and with what delay.) Corrects the visibility of the last 1-2 lines.

One reason for the use of such kata is not to “shine” strange and entertaining pictures that appear in tapes on the full screen in the office during working hours. The type of tape becomes more "business". Another is to restrict the texts of authors who have no sense of proportion in the size of annotations. The numbers “120”, “240” are optimal for the ZenComment style mode and can be changed directly in the script code (variable strongCutImgMinH). (Whether it is necessary to make the settings is an open question. After all, you can accidentally change and forget about it, and then think that these are errors of the script or the site. As, however, it happens now with filters on blogs on the site. With the numbers selected, it is forced The cat gets a relatively small part of the annotations (5-20%).)
All these methods of text reduction are a combination of a number of processing rules and can be disassembled in the text of a script by searching for the words “if (h.settings.strongCut.val)” and “h.settings.noAuthor.val”.