Changeset - 6a4f13866fe6
[Not reviewed]
default
0 2 0
Mads Kiilerich - 11 years ago 2015-03-25 20:17:35
madski@unity3d.com
gists: add missing formencode.htmlfill import
2 files changed with 4 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/admin/gists.py
Show inline comments
 
@@ -7,49 +7,49 @@
 
# This program is distributed in the hope that it will be useful,
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
# GNU General Public License for more details.
 
#
 
# You should have received a copy of the GNU General Public License
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
"""
 
kallithea.controllers.admin.gist
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

	
 
gist controller for Kallithea
 

	
 
This file was forked by the Kallithea project in July 2014.
 
Original author and date, and relevant copyright and licensing information is below:
 
:created_on: May 9, 2013
 
:author: marcink
 
:copyright: (c) 2013 RhodeCode GmbH, and others.
 
:license: GPLv3, see LICENSE.md for more details.
 
"""
 

	
 
import time
 
import logging
 
import traceback
 
import formencode
 
import formencode.htmlfill
 

	
 
from pylons import request, response, tmpl_context as c, url
 
from pylons.controllers.util import redirect
 
from pylons.i18n.translation import _
 

	
 
from kallithea.model.forms import GistForm
 
from kallithea.model.gist import GistModel
 
from kallithea.model.meta import Session
 
from kallithea.model.db import Gist, User
 
from kallithea.lib import helpers as h
 
from kallithea.lib.base import BaseController, render
 
from kallithea.lib.auth import LoginRequired, NotAnonymous
 
from kallithea.lib.utils import jsonify
 
from kallithea.lib.utils2 import safe_int, time_to_datetime
 
from kallithea.lib.helpers import Page
 
from webob.exc import HTTPNotFound, HTTPForbidden
 
from sqlalchemy.sql.expression import or_
 
from kallithea.lib.vcs.exceptions import VCSError, NodeNotChangedError
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
class GistsController(BaseController):
 
    """REST Controller styled on the Atom Publishing Protocol"""
kallithea/templates/admin/gists/new.html
Show inline comments
 
@@ -36,78 +36,78 @@
 
                <div class="gravatar">
 
                  ${h.gravatar(c.authuser.email, size=32)}
 
                </div>
 
                <textarea style="resize:vertical; width:400px;border: 1px solid #ccc;border-radius: 3px;" id="description" name="description" placeholder="${_('Gist description ...')}"></textarea>
 
                <div style="padding:0px 0px 0px 42px">
 
                <label for='lifetime'>${_('Gist lifetime')}</label>
 
                ${h.select('lifetime', '', c.lifetime_options)}
 
                </div>
 
            </div>
 
            <div id="body" class="codeblock">
 
                <div style="padding: 10px 10px 10px 26px;color:#666666">
 
                    ${h.text('filename', size=30, placeholder=_('name this file...'))}
 
                    <select id="mimetype" name="mimetype"/>
 
                </div>
 
                <div id="editor_container">
 
                    <pre id="editor_pre"></pre>
 
                    <textarea id="editor" name="content" style="display:none"></textarea>
 
                </div>
 
            </div>
 
            <div style="padding-top: 5px">
 
            ${h.submit('private',_('Create Private Gist'),class_="btn btn-mini btn-success")}
 
            ${h.submit('public',_('Create Public Gist'),class_="btn btn-mini")}
 
            ${h.reset('reset',_('Reset'),class_="btn btn-mini")}
 
            </div>
 
            ${h.end_form()}
 
            <script type="text/javascript">
 
          ${h.end_form()}
 
          <script type="text/javascript">
 
            var myCodeMirror = initCodeMirror('editor', '');
 

	
 
            //inject new modes
 
            var $modes_select = $('#mimetype');
 
            $modes_select.each(function(){
 
                var modes_select = this;
 
                var index = 1;
 
                for(var i=0;i<CodeMirror.modeInfo.length;i++) {
 
                    var m = CodeMirror.modeInfo[i];
 
                    var opt = new Option(m.name, m.mime);
 
                    $(opt).attr('mode', m.mode);
 
                    if (m.mime == 'text/plain') {
 
                        // default plain text
 
                        $(opt).attr('selected', 'selected');
 
                        modes_select.options[0] = opt;
 
                    } else {
 
                        modes_select.options[index++] = opt;
 
                    }
 
                }
 
            });
 

	
 
            var $filename = $('#filename');
 
            // on select change set new mode
 
            $modes_select.change(function(e){
 
                var selected = e.currentTarget;
 
                var node = selected.options[selected.selectedIndex];
 
                var detected_mode = CodeMirror.findModeByMIME(node.value);
 
                setCodeMirrorMode(myCodeMirror, detected_mode);
 

	
 
                var proposed_ext = CodeMirror.findExtensionByMode(detected_mode);
 
                var file_data = CodeMirror.getFilenameAndExt($filename.val());
 
                var filename = file_data['filename'] || 'filename1';
 
                $filename.val(filename + '.' + proposed_ext);
 
            });
 

	
 
            // on type the new filename set mode
 
            $filename.keyup(function(e){
 
                var file_data = CodeMirror.getFilenameAndExt(this.value);
 
                if(file_data['ext'] != null){
 
                    var detected_mode = CodeMirror.findModeByExtension(file_data['ext']) || CodeMirror.findModeByMIME('text/plain');
 
                    if (detected_mode){
 
                        setCodeMirrorMode(myCodeMirror, detected_mode);
 
                        $modes_select.val(detected_mode.mime);
 
                    }
 
                }
 
            });
 
            </script>
 
          </script>
 
        </div>
 
    </div>
 

	
 
</div>
 
</%def>
0 comments (0 inline, 0 general)