feat(website): ensure the inputs are mandatory
Move the forms to a partial (had a hard time with HAML-based partials...) Small box-shadow if not specified Add a "I'm the owner of that website" checkbox
This commit is contained in:
parent
6c7335cafc
commit
e59d132c2d
7 changed files with 88 additions and 56 deletions
|
|
@ -5,7 +5,7 @@ source 'https://rubygems.org'
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
gem 'jekyll', '< 3'
|
gem 'jekyll', '< 3'
|
||||||
gem 'haml'
|
gem 'jekyll-haml'
|
||||||
gem 'rouge'
|
gem 'rouge'
|
||||||
gem 'sass'
|
gem 'sass'
|
||||||
gem 'guard'
|
gem 'guard'
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,9 @@ GEM
|
||||||
jekyll
|
jekyll
|
||||||
jekyll-gist (1.4.0)
|
jekyll-gist (1.4.0)
|
||||||
octokit (~> 4.2)
|
octokit (~> 4.2)
|
||||||
|
jekyll-haml (0.1.3)
|
||||||
|
haml (>= 3.0.0)
|
||||||
|
jekyll (>= 0.10.0)
|
||||||
jekyll-paginate (1.1.0)
|
jekyll-paginate (1.1.0)
|
||||||
jekyll-sass-converter (1.3.0)
|
jekyll-sass-converter (1.3.0)
|
||||||
sass (~> 3.2)
|
sass (~> 3.2)
|
||||||
|
|
@ -127,9 +130,9 @@ DEPENDENCIES
|
||||||
guard-bundler
|
guard-bundler
|
||||||
guard-jekyll-plus
|
guard-jekyll-plus
|
||||||
guard-livereload
|
guard-livereload
|
||||||
haml
|
|
||||||
jekyll (< 3)
|
jekyll (< 3)
|
||||||
jekyll-contentblocks
|
jekyll-contentblocks
|
||||||
|
jekyll-haml
|
||||||
nokogiri
|
nokogiri
|
||||||
rouge
|
rouge
|
||||||
sass
|
sass
|
||||||
|
|
|
||||||
22
docs/_includes/join-form.haml
Normal file
22
docs/_includes/join-form.haml
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
%form.join-form{action: '#', method: 'POST'}
|
||||||
|
%h3 Get Started. It’s FREE!
|
||||||
|
.spacer20
|
||||||
|
.input-group
|
||||||
|
%span.input-group-addon
|
||||||
|
%i.fa.fa-fw.fa-globe
|
||||||
|
%input.form-control{type: 'text', placeholder: 'https://website.com/doc', name: 'url'}
|
||||||
|
%p.text-sm We’ll crawl the <u>documentation pages</u> of your website and index them on Algolia.
|
||||||
|
.spacer10
|
||||||
|
.input-group
|
||||||
|
%span.input-group-addon
|
||||||
|
%i.fa.fa-fw.fa-envelope-o
|
||||||
|
%input.form-control{type: 'email', placeholder: 'you@example.org', name: 'email'}
|
||||||
|
%p.text-sm We’ll email you the code you need to integrate the search into your documentation.
|
||||||
|
%p.checkbox.text-center
|
||||||
|
%label
|
||||||
|
%input{type: 'checkbox', name: 'owner'}
|
||||||
|
%span I'm the <u>owner</u> of that website
|
||||||
|
.spacer20
|
||||||
|
.text-center
|
||||||
|
%button.btn.btn-primary.btn-lg{type: 'submit'}
|
||||||
|
JOIN THE BETA!
|
||||||
|
|
@ -1,28 +1,40 @@
|
||||||
|
require 'jekyll-haml'
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
class HamlConverter < Converter
|
|
||||||
safe true
|
|
||||||
|
|
||||||
def setup
|
class HamlPartialTag < Liquid::Tag
|
||||||
return if @setup
|
def initialize(tag_name, file, tokens)
|
||||||
require 'haml'
|
super
|
||||||
@setup = true
|
@file = file.strip
|
||||||
rescue
|
|
||||||
STDERR.puts 'do `gem install haml`'
|
|
||||||
raise FatalException.new("Missing dependency: haml")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def matches(ext)
|
def render(context)
|
||||||
ext =~ /haml/i
|
includes_dir = File.join(context.registers[:site].source, '_includes')
|
||||||
end
|
|
||||||
|
|
||||||
def output_ext(ext)
|
if File.symlink?(includes_dir)
|
||||||
".html"
|
return "Includes directory '#{includes_dir}' cannot be a symlink"
|
||||||
end
|
end
|
||||||
|
|
||||||
def convert(content)
|
if @file !~ /^[a-zA-Z0-9_\/\.-]+$/ || @file =~ /\.\// || @file =~ /\/\./
|
||||||
setup
|
return "Include file '#{@file}' contains invalid characters or sequences"
|
||||||
engine = Haml::Engine.new(content)
|
end
|
||||||
engine.render
|
|
||||||
|
return "File must have \".haml\" extension" if @file !~ /\.haml$/
|
||||||
|
|
||||||
|
Dir.chdir(includes_dir) do
|
||||||
|
choices = Dir['**/*'].reject { |x| File.symlink?(x) }
|
||||||
|
if choices.include?(@file)
|
||||||
|
source = File.read(@file)
|
||||||
|
conversion = ::Haml::Engine.new(source).render
|
||||||
|
partial = Liquid::Template.parse(conversion)
|
||||||
|
return partial.render!(context).gsub(/\s+/, ' ')
|
||||||
|
else
|
||||||
|
"Included file '#{@file}' not found in _includes directory"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Liquid::Template.register_tag('haml', Jekyll::HamlPartialTag)
|
||||||
|
|
|
||||||
|
|
@ -129,12 +129,19 @@ html, body {
|
||||||
letter-spacing: 2px;
|
letter-spacing: 2px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
.input-group, .checkbox input {
|
||||||
|
&.has-errors {
|
||||||
|
-webkit-box-shadow: 0px 0px 20px 0px #FF2E6C;
|
||||||
|
-moz-box-shadow: 0px 0px 20px 0px #FF2E6C;
|
||||||
|
box-shadow: 0px 0px 20px 0px #FF2E6C;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 1200px) {
|
@media (min-width: 1200px) {
|
||||||
.jumbotron .join-form {
|
.jumbotron .join-form {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 200px;
|
top: 170px;
|
||||||
right: 120px;
|
right: 120px;
|
||||||
padding: 10px 40px 30px;
|
padding: 10px 40px 30px;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,24 +16,8 @@ layout: default
|
||||||
.text-center
|
.text-center
|
||||||
%p We’ve created the fastest, easiest way to search within documentation.
|
%p We’ve created the fastest, easiest way to search within documentation.
|
||||||
%p
And best of all? It’s FREE.
|
%p
And best of all? It’s FREE.
|
||||||
%form.join-form{action: '#', method: 'POST'}
|
|
||||||
%h3 Get Started. It’s FREE!
|
{% haml join-form.haml %}
|
||||||
.spacer20
|
|
||||||
.input-group
|
|
||||||
%span.input-group-addon
|
|
||||||
%i.fa.fa-fw.fa-envelope-o
|
|
||||||
%input.form-control{type: 'email', placeholder: 'you@example.org', name: 'email'}
|
|
||||||
%p.text-sm We’ll email you the code you need to integrate the search into your documentation.
|
|
||||||
.spacer20
|
|
||||||
.input-group
|
|
||||||
%span.input-group-addon
|
|
||||||
%i.fa.fa-fw.fa-globe
|
|
||||||
%input.form-control{type: 'text', placeholder: 'https://website.com/doc', name: 'url'}
|
|
||||||
%p.text-sm We’ll crawl the documentation pages of your website and index them on Algolia.
|
|
||||||
.spacer20
|
|
||||||
.text-center
|
|
||||||
%button.btn.btn-primary.btn-lg{type: 'submit'}
|
|
||||||
JOIN THE BETA!
|
|
||||||
#section_why.page-section
|
#section_why.page-section
|
||||||
.m800.m-l-r-auto
|
.m800.m-l-r-auto
|
||||||
%h2.page-section-title Why DocSearch?
|
%h2.page-section-title Why DocSearch?
|
||||||
|
|
@ -128,22 +112,8 @@ layout: default
|
||||||
%p We’ll get back to you within a few hours with everything you need to integrate your new search into your website.
|
%p We’ll get back to you within a few hours with everything you need to integrate your new search into your website.
|
||||||
%p Oh, and did we mention it's FREE? No commitment. No subscription. Everything is on us!
|
%p Oh, and did we mention it's FREE? No commitment. No subscription. Everything is on us!
|
||||||
.spacer30
|
.spacer30
|
||||||
%form.join-form{action: '#', method: 'POST'}
|
|
||||||
.input-group
|
{% haml join-form.haml %}
|
||||||
%span.input-group-addon
|
|
||||||
%i.fa.fa-fw.fa-envelope-o
|
|
||||||
%input.form-control{type: 'email', placeholder: 'you@example.org', name: 'email'}
|
|
||||||
%p.text-sm We’ll email you the code you need to integrate the search into your documentation.
|
|
||||||
.spacer20
|
|
||||||
.input-group
|
|
||||||
%span.input-group-addon
|
|
||||||
%i.fa.fa-fw.fa-globe
|
|
||||||
%input.form-control{type: 'text', placeholder: 'https://website.com/doc', name: 'url'}
|
|
||||||
%p.text-sm We’ll crawl the documentation pages of your website and index them on Algolia.
|
|
||||||
.spacer20
|
|
||||||
.text-center
|
|
||||||
%button.btn.btn-primary.btn-lg{type: 'submit'}
|
|
||||||
JOIN THE BETA!
|
|
||||||
|
|
||||||
{% contentfor site-footer %}
|
{% contentfor site-footer %}
|
||||||
<script src="{{ "/js/home.js" | prepend: site.baseurl }}"></script>
|
<script src="{{ "/js/home.js" | prepend: site.baseurl }}"></script>
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,24 @@
|
||||||
var $button = $(this).find('button');
|
var $button = $(this).find('button');
|
||||||
var $email = $(this).find('input[name="email"]');
|
var $email = $(this).find('input[name="email"]');
|
||||||
var $url = $(this).find('input[name="url"]');
|
var $url = $(this).find('input[name="url"]');
|
||||||
|
var $owner = $(this).find('input[name="owner"]');
|
||||||
|
var error = false;
|
||||||
|
$(this).find('.has-errors').removeClass('has-errors');
|
||||||
|
if (!$email.val()) {
|
||||||
|
$email.closest('.input-group').addClass('has-errors');
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
|
if (!$url.val()) {
|
||||||
|
$url.closest('.input-group').addClass('has-errors');
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
|
if (!$owner.is(':checked')) {
|
||||||
|
$owner.addClass('has-errors');
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
|
if (error) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$button.attr('disabled', true);
|
$button.attr('disabled', true);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'https://www.algolia.com/docsearch/join',
|
url: 'https://www.algolia.com/docsearch/join',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue