Permalink
Browse files

Working on Markdown field.

  • Loading branch information...
1 parent 463e278 commit 36b52b9a130f0666ca234b414f64045c1b8cb4ee @bobdenotter committed Oct 12, 2012
@@ -64,6 +64,8 @@ kitchensink:
slug:
type: slug
uses: title
+ markdown:
+ type: markdown
video:
type: video
html:
View
@@ -269,7 +269,13 @@ public function __call($name, $arguments)
return $output;
*/
-
+
+ $fieldtype = $this->fieldtype($name);
+
+ if ($fieldtype == "markdown") {
+ // TODO: convert to markdown..
+ }
+
return $this->values[$name];
} else {
@@ -403,7 +409,7 @@ public function excerpt($length=200) {
$excerpt = array();
foreach ($this->contenttype['fields'] as $key => $field) {
- if (in_array($field['type'], array('text', 'html', 'textarea'))
+ if (in_array($field['type'], array('text', 'html', 'textarea', 'markdown'))
&& isset($this->values[$key])
&& !in_array($key, array("title", "name")) ) {
$excerpt[] = $this->values[$key];
View
@@ -244,6 +244,7 @@ function repairTables() {
case 'html':
case 'textarea':
case 'video':
+ case 'markdown':
case 'geolocation':
$query = sprintf("ALTER TABLE `%s` ADD `%s` TEXT NOT NULL DEFAULT \"\";", $tablename, $field);
$this->db->query($query);
@@ -3,7 +3,7 @@
{# --------------- text --------------- #}
{% if field.type == "text" %}
-<label><b>{% if field.label is defined %}{{field.label}}{% else %}{{ key|ucfirst}}{%endif%}</b></label>
+<label xmlns="http://www.w3.org/1999/html"><b>{% if field.label is defined %}{{field.label}}{% else %}{{ key|ucfirst}}{%endif%}</b></label>
<input type="text" name="{{key}}" id="{{key}}"
value='{{ content.get(key) }}'
class='{% if field.class is defined %}{{ field.class }}{% endif %}'>
@@ -302,16 +302,53 @@ $("#field-{{key}}").autocomplete({
{% if content.get(key) is defined %}{{ content.get(key) }}{% endif %}
</textarea>
{% endif %}
-
+
{# --------------- textarea --------------- #}
{% if field.type == "textarea" %}
<label><b>{% if field.label is defined %}{{field.label}}{% else %}{{ key|ucfirst}}{%endif%}</b></label>
<textarea name="{{key}}" class='{% if field.class is defined %}{{ field.class }}{% endif %}'
style='{% if field.height is defined %}height: {{ field.height }} !important;{% endif %}'>{% if content.get(key) is defined %}{{ content.get(key) }}{% endif %}</textarea>
{% endif %}
-
-
+
+
+{# --------------- textarea --------------- #}
+
+{% if field.type == "markdown" %}
+ <label>
+ <b>{% if field.label is defined %}{{field.label}}{% else %}{{ key|ucfirst}}{%endif%}</b>
+ <span class="label info-pop" data-title="{% if field.label is defined %}{{field.label}}{% else %}{{ key|ucfirst}}{%endif%}"
+ data-content="Markdown is a text-to-HTML conversion tool for web writers.
+Markdown allows you to write using an easy-to-read, easy-to-write plain text format,
+which is then converted to structurally valid HTML.</p>
+
+<p><strong>Quick reference:</strong><br>
+# This is an &amp;lt;h1&amp;gt; tag<br>
+## This is an &amp;lt;h2&amp;gt; tag<br>
+###### This is an &amp;lt;h6&amp;gt; tag</p>
+
+<p>This _<em>is italic</em>_, this __<strong>is bold</strong>__, and this
+___<em><strong>is both</strong></em>___. You can also use asterixes: This *<em>is italic</em>*,
+this **<strong>is bold</strong>**.
+
+<p>Create <a href='#'>links</a> like this:<br>
+An [exciting website](http://example.org/ &amp;quot;Title of link&amp;quot;)</p>
+
+<p>&nbsp; * This is an unordered list<br>
+&nbsp; * Item 2</p>
+
+<p>&nbsp; 1 This is an ordered list<br>
+&nbsp; 2 Item 2</p>
+
+">
+ Info
+ </span>
+ </label>
+ <textarea name="{{key}}" class='{% if field.class is defined %}{{ field.class }}{% endif %}'
+ style='{% if field.height is defined %}height: {{ field.height }} !important;{% endif %}'>{% if content.get(key) is defined %}{{ content.get(key) }}{% endif %}</textarea>
+{% endif %}
+
+
{# --------------- date --------------- #}
{% if field.type == "date" %}
View
@@ -170,12 +170,15 @@ footer {
}
.popover {
- width: 360px;
+ width: 400px;
-webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 0 5px 10px rgba(0,0,0,0.5);
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.5);
}
+.popover-content p {
+ margin: 4px 0;
+}
/**
* Dashboard specific stuff
@@ -11,6 +11,8 @@ can output all fields. #}
<h2>{{ record.subtitle }}</h2>
{% endif %}
+ {{ record.markdown }}
+
{% for key,value in record.values %}
{% if key not in ['id', 'slug', 'datecreated', 'datechanged', 'username', 'status', 'title', 'subtitle'] %}
@@ -44,7 +46,9 @@ can output all fields. #}
{% endfor %}
<p class="meta">Posted by {{ record.user.displayname }} on {{ record.datecreated|date("M d, ’y")}}</p>
-
+
+ {{ print(record) }}
+
</article>
{% include '_footer.twig' %}

0 comments on commit 36b52b9

Please sign in to comment.