<commit_before>##############################################################################
#
# SageMathCloud: A collaborative web-based interface to Sage, IPython, LaTeX and the Terminal.
#
#    Copyright (C) 2014--2016, SageMath, Inc.
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    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/>.
#
##############################################################################
# Editor for HTML/Markdown/ReST documents
##############################################################################

_               = require('underscore')
async           = require('async')

misc            = require('smc-util/misc')
{defaults, required} = misc

misc_page       = require('../misc_page')

editor          = require('../editor')

{alert_message} = require('../alerts')
{salvus_client} = require('../salvus_client')
{IS_MOBILE}     = require('../feature')

{redux}         = require('../smc-react')
printing        = require('../printing')

templates       = $("#salvus-editor-templates")


class exports.HTML_MD_Editor extends editor.FileEditor

    constructor: (@project_id, @filename, content, @opts) ->
        super(@project_id, @filename)
        # The are two components, side by side
        #     * source editor -- a CodeMirror editor
        #     * preview/contenteditable -- rendered view
        # console.log("HTML_MD_editor", @)

        if @ext == 'html'
            @opts.mode = 'htmlmixed'
        else if @ext == 'md'
            @opts.mode = 'gfm'
        else if @ext == 'rmd'
            @opts.mode = 'gfm'
        else if @ext == 'rst'
            @opts.mode = 'rst'
        else if @ext == 'wiki' or @ext == "mediawiki"
            # canonicalize .wiki and .mediawiki (as used on github!) to "mediawiki"
            @ext = "mediawiki"
            @opts.mode = 'mediawiki'
        else if @ext != 'java'
            throw Error('file must have extension md, html, rmd, rst, tex, java, or wiki')

        @disable_preview = @local_storage("disable_preview")
        if not @disable_preview? and @opts.mode == 'htmlmixed'
            # Default the preview to be disabled for html, but enabled for everything else.
            # This is mainly because when editing the SMC source itself, the previews break
            # everything by emding SMC's own code in the DOM.  However, it is probably a
            # reasonable default more generally.
            @disable_preview = true

        @element = templates.find(".salvus-editor-html-md").clone()

        # create the textedit button bar.
        @edit_buttons = templates.find(".salvus-editor-textedit-buttonbar").clone()
        @element.find(".salvus-editor-html-md-textedit-buttonbar").append(@edit_buttons)

        @preview = @element.find(".salvus-editor-html-md-preview")
        @preview_content = @preview.find(".salvus-editor-html-md-preview-content")
        @preview.on 'scroll', =>
            @preview_scroll_position = @preview.scrollTop()
<commit_msg>hide text input buttons for java files<commit_after>##############################################################################
#
# SageMathCloud: A collaborative web-based interface to Sage, IPython, LaTeX and the Terminal.
#
#    Copyright (C) 2014--2016, SageMath, Inc.
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    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/>.
#
##############################################################################
# Editor for HTML/Markdown/ReST documents
##############################################################################

_               = require('underscore')
async           = require('async')

misc            = require('smc-util/misc')
{defaults, required} = misc

misc_page       = require('../misc_page')

editor          = require('../editor')

{alert_message} = require('../alerts')
{salvus_client} = require('../salvus_client')
{IS_MOBILE}     = require('../feature')

{redux}         = require('../smc-react')
printing        = require('../printing')

templates       = $("#salvus-editor-templates")


class exports.HTML_MD_Editor extends editor.FileEditor

    constructor: (@project_id, @filename, content, @opts) ->
        super(@project_id, @filename)
        # The are two components, side by side
        #     * source editor -- a CodeMirror editor
        #     * preview/contenteditable -- rendered view
        # console.log("HTML_MD_editor", @)
        $('.salvus-editor-textedit-buttonbar').show()
        if @ext == 'html'
            @opts.mode = 'htmlmixed'
        else if @ext == 'md'
            @opts.mode = 'gfm'
        else if @ext == 'rmd'
            @opts.mode = 'gfm'
        else if @ext == 'rst'
            @opts.mode = 'rst'
        else if @ext == 'wiki' or @ext == "mediawiki"
            # canonicalize .wiki and .mediawiki (as used on github!) to "mediawiki"
            @ext = "mediawiki"
            @opts.mode = 'mediawiki'
        else if @ext == 'java'
            $('.salvus-editor-textedit-buttonbar').hide()
        else
            throw Error('file must have extension md, html, rmd, rst, tex, java, or wiki')

        @disable_preview = @local_storage("disable_preview")
        if not @disable_preview? and @opts.mode == 'htmlmixed'
            # Default the preview to be disabled for html, but enabled for everything else.
            # This is mainly because when editing the SMC source itself, the previews break
            # everything by emding SMC's own code in the DOM.  However, it is probably a
            # reasonable default more generally.
            @disable_preview = true

        @element = templates.find(".salvus-editor-html-md").clone()

        # create the textedit button bar.
        @edit_buttons = templates.find(".salvus-editor-textedit-buttonbar").clone()
        @element.find(".salvus-editor-html-md-textedit-buttonbar").append(@edit_buttons)

        @preview = @element.find(".salvus-editor-html-md-preview")
        @preview_content = @preview.find(".salvus-editor-html-md-preview-content")
        @preview.on 'scroll', =>
            @preview_scroll_position = @preview.scrollTop()

{'fraction_non_alphanumeric': 0.17454846270508756, 'fraction_numerical': 0.002481731697228733, 'mean_word_length': 2.7488372093023257, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4503357', 'n_tokens_mistral': 2011, 'n_tokens_neox': 1925, 'n_words': 619}