%META:TOPICINFO{author="ProjectContributor" date="1252721244" format="1.1" version="1"}% %META:TOPICPARENT{name="ReferenceManual"}% %STARTINCLUDE% #MetaData ---+ Meta data _Additional data, Foswiki-generated or from [[DataForms][forms]], may be embedded in the topic text using =META:= macros_ %TOC% ---++ Overview The default store engines store topics in plain-text files on disk, in a simple and obvious directory structure. The big advantage of this approach is that it makes it very easy to manipulate topics from outside Foswiki, and it is also very robust; there are no complex binary indexes to maintain, and moving a topic from one installation to another is as simple as copying a couple of text files. To keep everything together in one place, meta-data (Foswiki-generated or from [[DataForms][forms]]) is embedded directly in topics, using special macros. These macros are easy to spot, as they all start with the reserved =META:= prefix. =META:= data includes information such as file attachments, topic movement history, and [[DataForms][form field]] values. For efficiency reasons, the topic history is *not* stored in this meta-data, but is expected to be implemented elsewhere by the store engine. ---++ Meta data syntax * Format is the same as for any other [[%SYSTEMWEB%.Macros][macros]] *except* that each meta-data macro *must* be on a line on its own. * =%META:<type>{key1="value1" key2="value2" ...}%= * The characters =%"\r\n{}= are encoded in argument values, using the standard URL encoding. * Meta-data is divided into _core_ meta-data, described below, and _extension_ meta-data, which shares the same syntax but is used by extensions. * Dates are stored as "epoch times" i.e. the integer number of seconds since 1st January 1970.
*Example of core meta-data*
%META:TOPICINFO{version="6" date="976762663" author="LastEditor" format="1.0"}%
   text of the topic
%META:TOPICMOVED{from="Real.SecretAgents" to="Hollywood.SecretAgents"
   by="CoverUp" date="976762680"}%
%META:TOPICPARENT{name="MilitaryIntelligence5"}%
%META:FILEATTACHMENT{name="CV.txt" version="3" ... }%
%META:FILEATTACHMENT{name="Photo.gif" version="1" ... }%
%META:FORM{name="SecretAgentForm"}%
%META:FIELD{name="ChosenWeapon" value="Beretta"}%
%META:FIELD{name="Paramour" value="PussyGalore"}%
%META:PREFERENCE{name="ALLOWTOPICCHANGE" value="JamesBond"}%
%META:PREFERENCE{name="DENYTOPICVIEW" value="ErnstBlofeld"}%
---++ Core meta-data The following meta-data macros are supported by the Foswiki core. Other macros may be used by extensions; see the extension documentation for more details. The core will read and write these extension macros, but will otherwise ignore them. Some fields are required by macros, while others are optional. Required fields are marked with a %REG% symbol. The %REG% character is *not* part of the attribute name. ---+++ META:TOPICINFO This macro caches some of the information that would normally be derived from the underlying store engine. It does this for efficiency reasons. | *Key* | *Comment* | | author%REG% | Canonical user identifier of last user to change the topic. The exact format of this depends on the user mapping manager. | | version | Topic version; a plain integer. | | date | epoch time | | format | Format of this topic, will be used for automatic format conversion | | reprev | Set when a revision is overwritten by the same author within the {ReplaceIfEditedAgainWithin} window (set in [[%SCRIPTURL{configure}%][ =configure= ]]). If =reprev= is the same as =version=, it prevents Foswiki from attempting to do a 3-way merge when merging overlapping edits by two different users. | Note that the *version and date fields are advisory only* and cannot be trusted. This is because processes outside of Foswiki's control may write topic files without maintaining these fields. ---+++ META:TOPICMOVED This only exists if the topic has been moved. If a topic is moved more than once, only the most recent META:TOPICMOVED meta datum exists in the topic. Older ones can to be found in the topic history.
%META:TOPICMOVED{from="Real.SecretAgents" to="Hollywood.SecretAgents" by="CoverUp" date="976762680"}%
| *Key* | *Comment* | | from%REG% | Full name, i.e., web.topic | | to%REG% | Full name, i.e., web.topic | | by%REG% | Canonical user identifier of who moved the topic. The exact format of this depends on the user mapping manager. | | date%REG% | epoch time | Notes: * the moved version numbers can be deduced from the topic history. ---+++ META:TOPICPARENT The topic from which this topic was created, typically when clicking on a =?= question mark link, or by filling out a form. The topic parent may also be manipulated in the user interface. | *Key* | *Comment* | | name%REG% | Normally just =TopicName=, but it can be a full =Web.TopicName= format if the parent is in a different Web. | ---+++ META:FILEATTACHMENT Reference to a file attached to this topic. | *Key* | *Comment* | | name%REG% | Name of file, no path. Must be unique within topic | | version | An integer | | path | Full path file was loaded from | | size | In bytes | | date | epoch time when the file was attached | | user | Canonical user identifier of user who uploaded the attachment. The exact format of this depends on the user mapping manager. | | comment | As supplied when file uploaded | | attr | =h= if hidden, optional | Extra fields that are added if an attachment is moved: | *Key* | *Comment* | | movedfrom | full topic name - web.topic.filename | | movedby | Canonical user identifier of user who moved the attachment. The exact format of this depends on the user mapping manager. | | movedto | full topic name - web.topic.filename | | moveddate | epoch time | ---+++ META:FORM | *Key* | *Comment* | | name%REG% | The name of the topic containing the [[DataForms][form definition]]. Can optionally include the web name (i.e., web.topic), but doesn't normally | ---+++ META:FIELD Should only be present if there is a =META:FORM= entry. | *Key* | *Name* | | name%REG% | Ties to entry in the [[DataForms][form definition]]. This is the title with all characters except alphanumerics and . removed | | value%REG% | Value user has supplied via form | | title | Full text from the [[DataForms][form definition]] | ---+++ META:PREFERENCE Out-of-band [[PreferenceSettings][preference]]. | *Key* | *Name* | | name%REG% | Preference name | | value%REG% | Preference value | | type | =Set= or =Local= (Set is the default) | ---+++ Recommended sequence There is no absolute need for meta-data macros to be listed in a specific order within a topic, but it makes sense to do so, because form fields are displayed in the order they are defined when the topic is viewed. The recommended sequence is: * =META:TOPICINFO= * =META:TOPICPARENT= (optional) * text of topic * =META:TOPICMOVED= (optional) * =META:FILEATTACHMENT= (0 or more entries) * =META:FORM= (optional) * =META:FIELD= (0 or more entries; FORM required) * =META:PREFERENCE= (0 or more entries) ---++ Viewing meta-data embedded in page source You can append the raw=debug parameter to the URL to view the topic text with embedded meta-data, e.g: debug view for this topic. raw=all lets you view the topic source as plain text, e.g: plain text view for this topic. #MetaDataRendering ---++ Including meta data in viewed topics ---+++ =%META= Meta-data belonging to the viewed topic can be included in the view using the =%META= macro. See VarMETA for details. ---+++ =%FORMFIELD= The =%FORMFIELD= macro lets you inspect the values of form field meta-data in other topics. See VarFORMFIELD for details. ---+++ =%SEARCH= =%SEARCH= can also be used to extract meta data. See VarSEARCH and the examples in FormattedSearch and SearchPatternCookbook. ---++ Extending meta-data in Extensions Extensions can extend meta-data with information of their own. See [[%SCRIPTURL{view}%/%SYSTEMWEB%/PerlDoc?module=Foswiki::Func#StaticMethod_registerMETA_40_36name_44_37syntax_41][Foswiki::Func]] for more information. --- *Related Topics:* DeveloperDocumentationCategory %META:PREFERENCE{name="REG" value="®"}%