Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
6 posts Page 1 of 1
If you wish to provide CSS editing via Couch and want to have a nice syntax highlighter then download the attached addon based on codemirror and call in into a message field as per the code below. Note the ID is "f_code" if you called your textarea for the CSS "custom_css" then you'd need to modify the following line to your field name with the f_ prefix:

var editor = CodeMirror.fromTextArea(document.getElementById("f_prefixed_textarea_name"), {});



Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:content_type 'text/css' />

<cms:template title='Style'>

    <cms:editable name='codemirror' type='message'>
        <style type="text/css">
            .CodeMirror {border-top: 1px solid #cccccc; border-bottom: 1px solid #cccccc;}
            .CodeMirror-activeline-background {background: #eeeeee !important;}
        </style>

        <link rel="stylesheet" href="<cms:show k_couch_link/>addons/codemirror/lib/codemirror.css">
        <script src="<cms:show k_couch_link/>addons/codemirror/lib/codemirror.js"></script>
        <script src="<cms:show k_couch_link/>addons/codemirror/mode/css/css.js"></script>
        <script src="<cms:show k_couch_link/>addons/codemirror/addon/selection/active-line.js"></script>
        <script>
            window.addEvent('domready', function(){
               var editor = CodeMirror.fromTextArea(document.getElementById("f_code"), {});
            });
        </script>   
    </cms:editable>

    <cms:editable name='code' label='CSS Code' type='textarea' />

</cms:template>

<?php COUCH::invoke(); ?>



For more information on front end stylesheet editing see this thread: - go down to KK's approach 2/3rds down the page

viewtopic.php?f=8&t=7371

Attachments

If you don't set no_xss_check='1' on the textarea, Couch will output escaped characters for " ' < >
Thanks cheesypoof! :)
I don't know if I intended that to be seen as a solution as it opens you up to XSS... Perhaps KK can comment on this.
.. as it opens you up to XSS

No worries here, @cheesypoof. The XSS factor only comes in when the input comes from an untrusted source (e.g. when we begin accepting contents from external users).

Since, in this case, the one inputting/editing the data will be the admin/super-admin, it is absolutely safe to turn off the XSS check.
Thanks for clarifying, as KK mentioned I wasn't too concerned as it would only be high level admin using this.
6 posts Page 1 of 1
cron