Synchronized build
This commit is contained in:
parent
667ea6923f
commit
66493e8a11
|
@ -202,9 +202,9 @@ method and set the <code>widget</code> property as a very basic requirement.</p>
|
||||||
to match the type name. If you want to name your type <code>mything</code> then it
|
to match the type name. If you want to name your type <code>mything</code> then it
|
||||||
needs to be called <code>MyThingType</code>. Afterwards you can register it with the
|
needs to be called <code>MyThingType</code>. Afterwards you can register it with the
|
||||||
environment in <a href="../../plugins/events/setup-env/" class="ref">setup_env</a>:</p>
|
environment in <a href="../../plugins/events/setup-env/" class="ref">setup_env</a>:</p>
|
||||||
<div class="hll"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.types</span> <span class="kn">import</span> <span class="n">Type</span>
|
<div class="hll"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.types.primitives</span> <span class="kn">import</span> <span class="n">SingleInputType</span>
|
||||||
|
|
||||||
<span class="k">class</span> <span class="nc">MyThingType</span><span class="p">(</span><span class="n">Type</span><span class="p">):</span>
|
<span class="k">class</span> <span class="nc">MyThingType</span><span class="p">(</span><span class="n">SingleInputType</span><span class="p">):</span>
|
||||||
<span class="n">widget</span> <span class="o">=</span> <span class="s1">'singleline-text'</span>
|
<span class="n">widget</span> <span class="o">=</span> <span class="s1">'singleline-text'</span>
|
||||||
|
|
||||||
<span class="k">def</span> <span class="nf">value_from_raw</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">raw</span><span class="p">):</span>
|
<span class="k">def</span> <span class="nf">value_from_raw</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">raw</span><span class="p">):</span>
|
||||||
|
@ -213,7 +213,10 @@ environment in <a href="../../plugins/events/setup-env/" class="ref">setup_env</
|
||||||
<span class="k">def</span> <span class="nf">setup_env</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">extra</span><span class="p">):</span>
|
<span class="k">def</span> <span class="nf">setup_env</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">extra</span><span class="p">):</span>
|
||||||
<span class="bp">self</span><span class="o">.</span><span class="n">env</span><span class="o">.</span><span class="n">add_type</span><span class="p">(</span><span class="n">MyThingType</span><span class="p">)</span>
|
<span class="bp">self</span><span class="o">.</span><span class="n">env</span><span class="o">.</span><span class="n">add_type</span><span class="p">(</span><span class="n">MyThingType</span><span class="p">)</span>
|
||||||
</pre></div>
|
</pre></div>
|
||||||
<p>For more information see <a href="value-from-raw/" class="ref">value_from_raw</a>.</p>
|
<div class="admonition admonition-tip"><p>In the above example, the new type declares a base class of <code>SingleInputType</code>.
|
||||||
|
This is appropriate for types that use a single-line input widget in the admin UI —
|
||||||
|
it enables the use of the <code>addon_label</code> <a href="/docs/models/#fields" class="ref">field option</a>.
|
||||||
|
Custom types that use more general input types should instead inherit from <code>lektor.types.base.Type</code>.</p></div><p>For more information see <a href="value-from-raw/" class="ref">value_from_raw</a>.</p>
|
||||||
<p>There is a more complete example in the
|
<p>There is a more complete example in the
|
||||||
<a href="../../../plugins/howto/#adding-new-field-types" class="ref">Plugin How To</a>.</p>
|
<a href="../../../plugins/howto/#adding-new-field-types" class="ref">Plugin How To</a>.</p>
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,9 @@
|
||||||
|
|
||||||
<li><a href="#dependency-tracking">Dependency Tracking</a></li>
|
<li><a href="#dependency-tracking">Dependency Tracking</a></li>
|
||||||
|
|
||||||
<li><a href="#adding-new-field-types">Adding New Field Types</a></li>
|
<li><a href="#adding-new-field-types">Adding New Field Types</a><ul>
|
||||||
|
<li><a href="#base-classes">Base Classes</a></li>
|
||||||
|
</ul></li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -289,6 +291,8 @@ code here
|
||||||
<span class="c1"># Derives type name "asciidoc" from class name.</span>
|
<span class="c1"># Derives type name "asciidoc" from class name.</span>
|
||||||
<span class="bp">self</span><span class="o">.</span><span class="n">env</span><span class="o">.</span><span class="n">add_type</span><span class="p">(</span><span class="n">AsciiDocType</span><span class="p">)</span>
|
<span class="bp">self</span><span class="o">.</span><span class="n">env</span><span class="o">.</span><span class="n">add_type</span><span class="p">(</span><span class="n">AsciiDocType</span><span class="p">)</span>
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
<h3 id="base-classes">Base Classes</h3><p>In the general case, new types should inherit from <code>lektor.types.base.Type</code>.
|
||||||
|
However, when creating a new type that will use a "single-line" input widget in the Admin GUI, inheriting from <code>lektor.types.primitives.SingleInputType</code> will enable the use of the <code>addon_label</code> <a href="/docs/models/#fields" class="ref">field option</a>.</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ speak multiple languages and allow you to easily create localized websites.</li>
|
||||||
<div class="slideshow-wrapper">
|
<div class="slideshow-wrapper">
|
||||||
<div class="slideshow">
|
<div class="slideshow">
|
||||||
<div class="slideshow-inner">
|
<div class="slideshow-inner">
|
||||||
<div class="carousel slide" data-ride="carousel" data-interval="8500" id="carousel-c27714a62e1244488f0b62c6bea47601">
|
<div class="carousel slide" data-ride="carousel" data-interval="8500" id="carousel-f265e5ee14484068b48548ac4b0067d5">
|
||||||
|
|
||||||
<div class="carousel-inner" role="listbox">
|
<div class="carousel-inner" role="listbox">
|
||||||
|
|
||||||
|
@ -210,11 +210,11 @@ be completely customized.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<a class="left carousel-control" href="#carousel-c27714a62e1244488f0b62c6bea47601" role="button" data-slide="prev">
|
<a class="left carousel-control" href="#carousel-f265e5ee14484068b48548ac4b0067d5" role="button" data-slide="prev">
|
||||||
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
|
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
|
||||||
<span class="sr-only">Previous</span>
|
<span class="sr-only">Previous</span>
|
||||||
</a>
|
</a>
|
||||||
<a class="right carousel-control" href="#carousel-c27714a62e1244488f0b62c6bea47601" role="button" data-slide="next">
|
<a class="right carousel-control" href="#carousel-f265e5ee14484068b48548ac4b0067d5" role="button" data-slide="next">
|
||||||
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
|
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
|
||||||
<span class="sr-only">Next</span>
|
<span class="sr-only">Next</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
Loading…
Reference in New Issue