Skip to content

Commit

Permalink
Styling and minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Simbiat committed May 21, 2021
1 parent 7af2e0f commit 309a61d
Show file tree
Hide file tree
Showing 16 changed files with 523 additions and 544 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# HTTP20
Set of classes/functions that may be universally useful for websites (or some parts of them, at least).
Set of classes/functions that may be universally useful for websites (or some parts of them, at least).
They are provided in single library and not separately, not only because of some inter-dependencies, but also because if you are building a website from scratch, most likely, you will be interested in a bunch of them at the same time either way.

- [HTTP20](#HTTP20)
Expand All @@ -11,7 +11,7 @@ They are provided in single library and not separately, not only because of some
+ [download](doc/Sharing.md#download)
+ [upload](doc/Sharing.md#upload)
+ [streamCopy](doc/Sharing.md#streamcopy)
+ [speedLimit](doc/Sharing.md#speedlimit)
+ [speedLimit](doc/Sharing.md#speedLimit)
+ [phpMemoryToInt](doc/Sharing.md#phpmemorytoint)
+ [rangesValidate](doc/Sharing.md#rangesvalidate)
+ [fileEcho](doc/Sharing.md#fileecho)
Expand Down
4 changes: 2 additions & 2 deletions doc/Common.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ reductor($files, string $type, bool $minify = false, string $toFile = '', string
```
Function to merge CSS/JS files to reduce number of connections to your server, yet allow you to keep the files separate for easier development. It also allows you to minify the result for extra size saving, but be careful with that.
Minification is based on https://gist.github.com/Rodrigo54/93169db48194d470188f
`$files` can be a string, a path to file, a path to folder or an array of filepaths.
`$files` can be a string, a path to file, a path to folder or an array of file paths.
`$type` can be anything, technically, but currently `css`, `js` or `html` are supported.
`$minify` trigger the minification if set to `true`. It's set to `false` by default, because minifcation is known to cause some issues, especially with HTML, so you need to be careful with this.
`$minify` trigger the minification if set to `true`. It's set to `false` by default, because minification is known to cause some issues, especially with HTML, so you need to be careful with this.
`$toFile` allows to output the data to a file, instead of to browser. Useful if you do not want to do this dynamically, but would rather prepare the files beforehand.
`$cacheStrat` is an optional caching strategy to apply (as described for [cacheControl](doc/Headers.md#cachecontrol))
`$exit` if set to `true` will exit the script, if to `false` - return an `int` representing the HTTP status code, unless text, font or some image/application MIME types is encountered: in this case `zEcho` will be used, which will exit the code regardless.
Expand Down
24 changes: 12 additions & 12 deletions doc/HTML.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ Functions, that generate useful HTML code.
```php
breadcrumbs(array $items, string $delimiter = '>', bool $links = false, bool $headers = false);
```
Generates breadcrumbs for your website in Microdata format (as per https://schema.org/BreadcrumbList) wrapping it in proper `<nav>` tag with `id` attributes for `<li>`, `<a>`, `<span>` tags, as well as useful `aria` attributes, where applicable. `id` values are structures in a way, that allows you to style items depending on their "level" (for example always hide first element, since it's supposed to be your home page): first item will always have an `id` ending with `0` and the last one - with `1`.
`$items` is an array of the items (arrays) you plan to present as breadcrumbs. Each array needs to have `href` and `name` elements, otherwise it will be skipped.
`$delimiter` is an optional delimiter, that you want to use between elements in breadcrumb. Usually this is a `>` symbol, which is set by default, but you can replace it with whatever you want (for example `<i class="bread-delimiter"></i> to have some unique icon).
Generates breadcrumbs for your website in Microdata format (as per https://schema.org/BreadcrumbList) wrapping it in proper `<nav>` tag with `id` attributes for `<li>`, `<a>`, `<span>` tags, as well as useful `aria` attributes, where applicable. `id` values are structures in a way, that allows you to style items depending on their "level" (for example always hide first element, since it's supposed to be your home page): first item will always have an `id` ending with `0` and the last one - with `1`.
`$items` is an array of the items (arrays) you plan to present as breadcrumbs. Each array needs to have `href` and `name` elements, otherwise it will be skipped.
`$delimiter` is an optional delimiter, that you want to use between elements in breadcrumb. Usually this is a `>` symbol, which is set by default, but you can replace it with whatever you want (for example `<i class="bread-delimiter"></i>` to have some unique icon).
`$links` - if set to `false`, you will get just a string of the requested breadcrumbs, but if set to `true`, this will also generate values for `rel="home index top begin prefetch"` and `rel="up prefetch"` required for `Links()` [function](Headers.md#links), and thus function will return an array like this:
```php
[
'breadcrumbs' => 'string_of_breadcrumbs',
'links' => [...],
]
```
You can then manually send the `'links'` array to `Links()` function to generate respective tags or headers.
`$headers` is checked only if `$links` is `true`. If `$headers` is also `true`, then it will directly send the `Link` header(s) and the return array value of `'links'` will have pre-generated set of `<link>` tags. While neither the headers nor the tags are required, they may asisst with navigation or peformance improvement for the client (due to `prefetch`).
You can then manually send the `'links'` array to `Links()` function to generate respective tags or headers.
`$headers` is checked only if `$links` is `true`. If `$headers` is also `true`, then it will directly send the `Link` header(s), and the return array value of `'links'` will have pre-generated set of `<link>` tags. While neither the headers, nor the tags are required, they may assist with navigation or performance improvement for the client (due to `prefetch`).

## pagination
```php
pagination(int $current, int $total, int $maxNumerics = 5, array $nonNumerics = ['first' => '<<', 'prev' => '<', 'next' => '>', 'last' => '>>', 'first_text' => 'First page', 'prev_text' => 'Previous page', 'next_text' => 'Next page', 'last_text' => 'Last page', 'page_text' => 'Page '], string $prefix = '', bool $links = false, bool $headers = false)
```
Generates pagination as `<ol>` list wrapped in `<nav>` with proper `id` and `aria` attributes.
`$current` - current page number.
`$total` - total number of pages.
`$maxNumerics` - maximum number of numeric links, that is those pages, that show actual numbers, and not 'First'/'Previous'/'Next'/'Last'. This number includes the current page.
Generates pagination as `<ol>` list wrapped in `<nav>` with proper `id` and `aria` attributes.
`$current` - current page number.
`$total` - total number of pages.
`$maxNumerics` - maximum number of numeric links, that is those pages, that show actual numbers, and not 'First'/'Previous'/'Next'/'Last'. This number includes the current page.
`$nonNumerics` is an array of default text values to style 'First', 'Previous', 'Next' and 'Last' pages (with some default values):
```php
[
Expand All @@ -52,13 +52,13 @@ Generates pagination as `<ol>` list wrapped in `<nav>` with proper `id` and `ari
'page_text' => 'Page ',
]
```
`$prefix` is an optional prefix for the links used in `href` attribute. Generally you will be ok with an empty string (default) and respective relative links, but in some cases, you may want to change that, for example, if your pages are using links like `#1` or `?page=1`. You can use that setting to adjust accordingly.
`$prefix` is an optional prefix for the links used in `href` attribute. Generally you will be ok with an empty string (default) and respective relative links, but in some cases, you may want to change that, for example, if your pages are using links like `#1` or `?page=1`. You can use that setting to adjust accordingly.
$links` - if set to `false`, you will get just a string of the requested pagination, but if set to `true`, this will also generate values for `rel="first prefetch"`, `rel="prev prefetch"`, `rel="next prefetch"` and `rel="last prefetch"` required for `Links()` [function](Headers.md#links), and thus function will return an array like this:
```php
[
'pagination' => 'string_of_pagination',
'links' => [...],
]
```
You can then manually send the `'links'` array to `Links()` function to generate respective tags or headers.
`$headers` is checked only if `$links` is `true`. If `$headers` is also `true`, then it will directly send the `Link` header(s) and the return array value of `'links'` will have pre-generated set of `<link>` tags. While neither the headers nor the tags are required, they may asisst with navigation or peformance improvement for the client (due to `prefetch`).
You can then manually send the `'links'` array to `Links()` function to generate respective tags or headers.
`$headers` is checked only if `$links` is `true`. If `$headers` is also `true`, then it will directly send the `Link` header(s), and the return array value of `'links'` will have pre-generated set of `<link>` tags. While neither the headers, nor the tags are required, they may assist with navigation or performance improvement for the client (due to `prefetch`).
Loading

0 comments on commit 309a61d

Please sign in to comment.