https://github.com/gocom/rah_metas
Automatic article meta handling for Textpattern CMS
https://github.com/gocom/rah_metas
Last synced: 8 months ago
JSON representation
Automatic article meta handling for Textpattern CMS
- Host: GitHub
- URL: https://github.com/gocom/rah_metas
- Owner: gocom
- License: gpl-2.0
- Created: 2012-01-31T03:20:54.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2012-07-28T02:04:00.000Z (almost 14 years ago)
- Last Synced: 2025-09-05T07:46:16.421Z (9 months ago)
- Language: PHP
- Homepage: http://rahforum.biz/plugins/rah_metas
- Size: 126 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.textile
- License: LICENSE
Awesome Lists containing this project
README
h1. rah_metas
p. A tiny meta-generator plugin for "Textpattern CMS":http://www.textpattern.com. Rah_metas auto-generates meta data from article content, including descriptions and keywords.
h2. List of features
* Generates automatic metadescriptions from article's body, excerpt or custom field.
* Limit and customize the automatic descriptions and keywords by word or character limits.
* Takes care of content validation. Strips all HTML, invalid characters and extra whitespace.
h2. Requirements
p. Minimum requirements:
* PHP 5+
* Textpattern 4.0.4+
p. Recommended:
* PHP 5.1.2+
* Textpattern 4.4.1+
h2. Installation and usage
p. The general behavior stands: paste plugin code to the plugin installer textarea and run the automatic setup. Then just activate the plugin and you are ready to use new tags that plugin includes like others.
p. For usage, basically just put @@-tag with wanted attributes to inside your site's @@-tags. As the plugin's tag outputs metainformation, and meta-tags, it shouldn't be used outside @@-tags.
h2. Attributes
p. The tag is @@ and attributes for it follow. Default value @""@ means that the attribute is unset and by default not used.
p. *imagetoolbar*
To block an browser's image toolbar. Allowed attributes are @true@ and @false@. By default not used.
Example: @imagetoolbar="false"@ Default: @""@
p. *language*
The language used by the site. Value should be a language code, for example @en@, @de@, @it@ or @se@.
Example: @language="en"@ Default: @""@
p. *robots*
Directs how robots should navigate on the page. Valid values include @index@, @noindex@, @follow@, @nofollow@. The values can be combined.
Example: @robots="index, follow"@ Default: @""@
p. *author*
Author name that you want to show as the page's author. Usually you, company or the website's name. This value is used as the fallback when @useauthor@ is used, but no author is available.
Example: @author="John Doe"@ Default: @""@
p. *useauthor*
If set to @1@, @@ is used to populate author metadata when possible. The value set with @author@ attribute will be used as a fallback in list context and such.
Example: @useauthor="1"@ Default: @"0"@
p. *copyright*
Outputs copyright meta. Value is used as the content.
Example: @copyright="Copyrihts © 2007 John Doe"@ Default: @""@
h3. Description related attributes
p. *description*
A default meta description that will be shown in list context, or when there isn't an article description to show and @description_replacement@ is set on.
Example: @description="Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Fusce at dui eget est congue aliquet. Quisque sed nunc"@ Default: @""@
p. *description_from*
Which artile field is used for the automatic meta description. The attribute takes comma separated list of fields. The first field in the list that isn't empty is used as the meta description. Available values: @body@, @excerpt@ or custom field's name. If set empty, the automatic description isn't used.
Example: @description_from="body,excerpt,metadescription"@ Default: @"body,excerpt"@
p. *words*
Limits the amount of words shown in the automatic meta description.
Example: @words="15"@ Default: @"25"@
p. *maxchars*
The maximum number of characters used in the generated automatic meta description.
Example: @maxchars="170"@ Default: @"250"@
p. *description_trail*
Ending trail used in the end of the automatic metadescription. Trail is only shown if the description is longer than the limit set by @maxchars@ and/or @words@.
Example: @description_trail=""@ Default: @"…"@
p. *description_replacement*
If set on (@1@) and there isn't automatic description available, @description@ attribute is used as the description instead. By default this feature is not used.
Example: @description_replacement="1"@ Default: @""@
p. *escape*
If set to @1@, will remove raw Textile markup from the description. By default the attribute is unset, and the feature is not used. Usually this feature isn't required, but it might be good if you are supplying the description in a custom field and you are using Textile there. Textile in custom fields isn't, by default, parsed by Textpattern.
Example: @escape="1"@ Default: @""@
h3. Keyword related attributes
p. *keywords*
Default keywords that will be used as keyword meta in a list context, or when there isn't any keywords set for an article and @keywords_replacement@ attribute is set on.
Example: @keywords="life, Doe, cat, dog"@ Default: @""@
p. *keywords_from*
Which field is used for the keyword meta. The attribute takes comma separated list of fields. The first field in the list that isn't empty is used as the keywords. Available values, any article field: @keywords@, @body@, @excerpt@ or custom field's name. If empty, the feature isn't used.
Example: @keywords_from="keywords,excerpt"@ Default: @"keywords"@
p. *keywords_replacement*
If there isn't keywords available for an article, use default defined in @keywords@ attribute instead.
Example: @keywords_replacement="1"@ Default: @""@
p. *keywords_limit*
Limits the words used in the keywords. Takes a number.
Example: @keywords_limit="5"@ Default: @"25"@
h4. Redirect related attributes
p. *messy_to_clean_redirect*
Use messy to clean redirect. Redirects messy requrests to clean urls. Use this only if you use clean urls. With messy urls this only causes eternal loop.
Example: @messy_to_clean_redirect="1"@ Default: @""@
p. *redirect_code*
The code of redirection, value should be "three numeric stannard status code protocol.":http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
Example: @redirect_code="302"@ Default: @"301"@
h3. Rel link related attributes
p. *relnext*
Use rel link to point next page's location to the browser. @relnext@ attribute's value is used as @@ tag's @title@. Ideal values are @Next@, @Go to next@ and so on. The attribute, @relnext@, adds a next rel link meta that points to the next section page or article by posting date. If attribute is used (filled) then used, if unset (empty) then not.
Example: @relnext="Next"@ Default: @""@
p. *relprev*
Use rel link to point previous page's location to the browser. @relprev@ attribute's value is used as @@ tag's @title@. Ideal values are @Previous@, @Go to prev@ and so on. The attribute, @relprev@, adds a next rel link meta that points to the previous section page or article by posting date. If attribute is used (filled) then used, if unset (empty) then not.
Example: @relprev="Previous"@ Default: @""@
p. *prev_url*
Manually defines relative prev url. Value should be a URL address. The URL is only used if automatic URL isn't found.
Example: @prev_url="http://www.example.com/path/to/id"@ Default: @""@
p. *next_url*
Manually defines relative next url. Value should be a URL address. The URL is only used if automatic URL isn't found.
Example: @prev_url="http://www.example.com/path/to/id"@ Default: @""@
h2. Examples
h3. Basic usage
bc.
h3. Using content preferring.* First look at the custom field, then main article (excerpt, body) fields.
bc.
h3. Using rah_metas tag inside "article_custom":http://textpattern.net/wiki/index.php?title=article_custom block
p. If rah_metas is placed directly inside article_custom (or article) tag, it can be used to pull the meta data from that specific article.
bc.
In the code above, we took the meta data from the article where the ID is 5.
h3. How to not output description at all, but keep all other features intact?
bc.
p. If @description@ and @description_from@ are set empty, no description will be generated. Same applies to keywords (see @keywords@ and @keywords_from@ attributes).
h2. Changelog
h3. Version 1.5 - 2011/10/29
* Wrapped set of extra functions into a class, and removed the prefixing from the new methods.
* Added comments, cleaned up some code.
* Removed @rah_metas_textile()@ function.
h3. Version 1.4 - 2010/10/19
* Now automatically converts values supplied in @keywords_from@ and @description_from@ to lowercase. "Thank you for reporting, pompilos":http://forum.textpattern.com/viewtopic.php?pid=236051#p236051.
* Now uses @lAtts()@ just once.
* Removed dublicated @trim()@ from @rah_metas_strip()@.
* Removed @rah_metas_atts()@.
h3. Version 1.3 - 2010/05/23
* Now @description_from@ and @keywords_from@ take comma separated list of fields. The first field in the list that isn't empty is used as keywords or description.
* Removed attribute @prefercontent@. Using the attribute will throw notice in testing or debugging mode.
h3. Version 1.2 - 2010/05/15
* Now the @@ tag can be also used _directly inside_ @@ and @@ blocks. That means that the tag now works in article lists. You just have to point it to the article. See example number 3.
* Now _any_ article field can be used in @description_from@ and @keywords_from@ attributes. Even title, authorid, override_form or status.
* Now dublicate keyword "uniqueing" is done with @array_unique()@.
* Fixed keywords code escaping.
h3. Version 1.1 - 2009/10/09
* Added: attribute @keywords_limit@.
* Added: removes doublicated words from keywords.
* Added: list view's description is effected by word and character limits.
* Fixed double @"="@ define bug.
* Now @escape@ attribute effects also body and expert, not only custom fields.
* Now keywords are escaped, striped for tags and parsed.
* Counts white space into chars.
* Removed imagetoolbar attribute validation.
h3. Version 1.0.5 - 2008/12/25
* Added attribute: @escape@.
* Rebuild description's word and chars counting: now always counts correctly: doesn't ever cut words.
* Optimized parsing and speed: plugin is around 20% faster than before.
* Removes @…@ from end of the description if trails are used and description is cut from context and shortened.
h3. Version 1.0.4 - 2008/11/12
* Added attribute: @relnext@.
* Added attribute: @relprev@.
* Minified amount of used globals by one.
h3. Version 1.0.3 - 2008/08/03
* Fixed last words truncate bug.
h3. Version 1.0.2 - 2008/06/17
* Fixed some typos in documention.
* Now @prefercontent@ also works with custom_fields.
h3. Version 1.0.1 - 2008/06/17
* Debugged version 1.0: status now stable.
* Fixed a bug: now whitespace is stripped from beginning and end of the description content.
h3. Version 1.0 - 2008/06/17
* Improved documentation.
* Little speed improvement.
* Removed @charset@-attribute, it ain't needed as Textpattern sends charset via headers - and it must not differ.
* Merged @customfieldexcerpt@-attribute with @description_from@.
* Included redirecting functions that prevent double content when using clean urls.
* Validates @imagetoolbar@-attribute to false or true.
* Added attribute: @description_replacement@.
* Added attribute: @keywords_replacement@.
* Added attribute: @description_from@
* Added attribute: @messy_to_clean_redirect@.
* Added attribute: @redirect_code@.
* Added attribute: @description_trail@.
* Added invalid charasters removing for custom fields.
* Removed Textile removing from body and excerpt, that was meant to remove Textile + XHTML bugs caused by user's invalid article code, and used instead body_html, and just stripped HTML: it's faster.
* Some users wanted to be able input invalid characters to description: now it is possible, if you turn Textile off: why should we validate meta description, if article's body itself is invalid, because writer doesn't use valid HTML special characters.
h3. Version minor 0.9.2 - 2008/01/07
* One bug fix, created by little one chars typo in the code.
h3. Version minor 0.9.1 - 2007/12
* Removed a debugging error, caused by undefined variable if there were no description.
h3. Version 0.9 - 2007/12/05
* Added attribute: @copyright@.
* Added attribute: @useauthor@.
* Added attribute: @customfieldkeywords@.
* Added attribute: @customfieldexcerpt@.
h3. Version 0.8 - 2007/11/02
* Added Textile remover: removes Textile completely from description
* Cleaned up the code
h3. Version 0.7 - 2007/09/08
* Fixed bug that appears if single article has no body or excerpt. Only shown in debugging.
h3. Version 0.6 - 2007/08/26
* Fixed a code-removing bug
* Now removes all code from automatic metadescription
h3. Version 0.5 - 2007/08
* Finished bug-testing
h3. Version 0.4 - 2007/08
* Add missing variable
h3. Version 0.3 - 2007/08
* Compined two separated functions
* Improved the code by fixing globals
h3. Version 0.2 - 2007/08
* Replaced automatic-medescription's ending points @…@ with @…@
* Added new attribute: @imagetoolbar@
h3. Version 0.1 - 2007/07/27
* Initial release.
h2. Thanks to
* All folks that thanked me by making this plugin available.
* rolograaf and pat64 for great ideas of keywords.
* fuls, strawberryfusion, jim_01, pompilos and ian_ep for reporting me some bugs.
* maniqui for the ideas.
* And all the other great Textpatternists.