<commit_before># Creates new HTML file.

'use strict'

base = require '../base'
fs = require 'fs'

module.exports = class Generator extends base

Generator::askFor = ->
	done = @async()
	prompts = [
		{
			name: 'name'
			message: 'File name'
			default: 'index'
		},
		{
			name: 'lang'
			message: 'Language'
			default: 'en'
		},
	]

	@prompt prompts, (props) =>
		@_.extend this, props
		done()

Generator::files = ->
	done = @async()

	filepath = "#{@name}.html"
	@stopIfExists filepath

	write = =>
		if bowerJson
			bower = @readJsonFile bowerJson
			jqueryVer = bower.version
			if @lang is 'ru'
				@jqueryPath = "http://yandex.st/jquery/#{jqueryVer}/jquery.min.js"
			else
				@jqueryPath = "http://ajax.googleapis.com/ajax/libs/jquery/#{jqueryVer}/jquery.min.js"

		@echo()
		@template 'html.html', filepath
		fs.unlinkSync bowerJson  unless @localJquery
		done()

	bowerJson = 'bower_components/jquery/bower.json'
	if fs.existsSync bowerJson
		@localJquery = true
		write()
	else
		@localJquery = false
		bowerJson = '__bwr.json'
		remoteBowerJson = 'https://raw.github.com/components/jquery/master/bower.json'
		@fetch remoteBowerJson, bowerJson, (err) =>
			@stop "Cannot download #{remoteBowerJson}"  if err
			write()

	@openInEditor filepath<commit_msg>HTML: --no-js option.<commit_after># Creates new HTML file.
#
# Options:
#   --no-js: Do not create links to jQuery and scripts file.

'use strict'

base = require '../base'
fs = require 'fs'

module.exports = class Generator extends base

Generator::options = ->
	@js = @options.js ? true

Generator::askFor = ->
	done = @async()
	prompts = [
		{
			name: 'name'
			message: 'File name'
			default: 'index'
		},
		{
			name: 'lang'
			message: 'Language'
			default: 'en'
		},
	]

	@prompt prompts, (props) =>
		@_.extend this, props
		done()

Generator::files = ->
	done = @async()

	filepath = "#{@name}.html"
	@stopIfExists filepath

	write = =>
		if @js and bowerJson
			bower = @readJsonFile bowerJson
			jqueryVer = bower.version
			if @lang is 'ru'
				@jqueryPath = "http://yandex.st/jquery/#{jqueryVer}/jquery.min.js"
			else
				@jqueryPath = "http://ajax.googleapis.com/ajax/libs/jquery/#{jqueryVer}/jquery.min.js"
			@delete bowerJsonDir  if bowerJsonDir

		@templateAndOpen 'html.html', filepath
		done()

	if @js
		bowerJson = 'bower_components/jquery/bower.json'
		if fs.existsSync bowerJson
			@localJquery = true
			write()
		else
			@localJquery = false
			bowerJsonDir = '__bwr'
			bowerJson = "#{bowerJsonDir}/bower.json"
			remoteBowerJson = 'https://raw.github.com/components/jquery/master/bower.json'
			@fetch remoteBowerJson, bowerJsonDir, (err) =>
				@stop "Cannot download #{remoteBowerJson}"  if err
				write()
	else
		write()
{'fraction_non_alphanumeric': 0.1474147414741474, 'fraction_numerical': 0.0, 'mean_word_length': 3.4, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1420440', 'n_tokens_mistral': 1108, 'n_tokens_neox': 980, 'n_words': 229}