Browse Source

remove contact form (#52)

pull/53/head
Cian Butler 4 years ago
committed by GitHub
parent
commit
e9074afa82
9 changed files with 59 additions and 93 deletions
  1. +1
    -1
      layout/common/committee.ejs
  2. +0
    -25
      layout/common/contact.ejs
  3. +1
    -1
      scripts/paypal.js
  4. +4
    -1
      scripts/thumbnail.js
  5. +0
    -32
      source/js/contact.js
  6. +0
    -20
      source/js/form.js
  7. +41
    -10
      source/js/insight.js
  8. +3
    -1
      source/js/main.js
  9. +9
    -2
      source/js/share.js

+ 1
- 1
layout/common/committee.ejs View File

@@ -1,7 +1,7 @@
<div class="cmt">
<% for (var i in post.cmt) { %>
<div class="cmt__member">
<a href="/about/contact/<%- post.cmt[i].nick %>">
<a href="mailto:<%- post.cmt[i].nick %>@redbrick.dcu.ie">
<div class="cmt__member__title"><%- post.cmt[i].position %></div>
<% if (post.cmt[i].resigned) { %>
<div class="cmt__member__image cmt__member__image__resigned">


+ 0
- 25
layout/common/contact.ejs View File

@@ -1,25 +0,0 @@
<div id="contact">
<form class="form" id="contact">
<fieldset class="field">
<input class="input" type="email" id="email" placeholder="example@domain.com" required>
<label class="label" for="email"><span class="label-content">Your email</span></label>
</fieldset>
<fieldset class="field">
<input class="input" type="text" id="fullname" placeholder="Name" required>
<label class="label" for="fullname"><span class="label-content">Your name</span></label>
</fieldset>
<fieldset class="field">
<input class="input" type="text" id="subject" placeholder="subject" required>
<label class="label" for="subject"><span class="label-content">subject</span></label>
</fieldset>
<fieldset class="field message">
<textarea class="input" id="content" rows="1" placeholder="Message" required></textarea>
<label class="label" for="content"><span class="label-content">Your message</span></label>
</fieldset>
<div class="g-recaptcha" data-sitekey="<%= theme.plugins.google_recaptcha %>" requried></div>
<fieldset class="field">
<button class="button submit">Send Email</button>
</fieldset>
</form>
<span id="message"></span>
</div>

+ 1
- 1
scripts/paypal.js View File

@@ -6,4 +6,4 @@ hexo.extend.tag.register('paypal', () => {
const htmlTmlSrc = path.join(__dirname, '..', 'layout', 'paypal.ejs');
const htmlTml = ejs.compile(fs.readFileSync(htmlTmlSrc, 'utf-8'));
return htmlTml({});
})
});

+ 4
- 1
scripts/thumbnail.js View File

@@ -4,4 +4,7 @@
* @example
* <%- thumbnail(post) %>
*/
hexo.extend.helper.register('thumbnail', ({ thumbnail, banner }) => thumbnail || banner || '');
hexo.extend.helper.register(
'thumbnail',
({ thumbnail, banner }) => thumbnail || banner || ''
);

+ 0
- 32
source/js/contact.js View File

@@ -1,32 +0,0 @@
$(document).ready(() => {
const site = window.location.origin;
let email;
let name;
let subject;
let text;
let recaptcha;
let to = window.location.pathname;
to = to.substring(to.lastIndexOf('/') + 1);
$('#contact').submit(e => {
recaptcha = grecaptcha.getResponse();
if (recaptcha === '') {
e.preventDefault();
$('#message').empty().html('complete recaptcha');
} else {
e.preventDefault();
email = $('#email').val();
name = $('#fullname').val().trim();
subject = $('#subject').val().trim();
text = $('#content').val().trim();
$('#message').text('Sending E-mail');
$.get(`${site}/api/contact`, { email, to, name, subject, text, recaptcha }, ({ formSubmit, errors }) => {
if (!formSubmit) {
$('#message').empty().html('Error in recaptcha');
} else {
const message = errors || 'Email Sent';
$('#message').empty().html(message);
}
});
}
});
});

+ 0
- 20
source/js/form.js View File

@@ -1,20 +0,0 @@
[].slice.call(document.querySelectorAll('.input')).forEach(inputEl => {
// in case the input is already filled..
if (inputEl.value.trim() !== '') {
classie.add(inputEl.parentNode, 'input--filled');
}

// events:
inputEl.addEventListener('focus', onInputFocus);
inputEl.addEventListener('blur', onInputBlur);
});

function onInputFocus ({ target }) {
classie.add(target.parentNode, 'input--filled');
}

function onInputBlur ({ target }) {
if (target.value.trim() === '') {
classie.remove(target.parentNode, 'input--filled');
}
}

+ 41
- 10
source/js/insight.js View File

@@ -11,7 +11,9 @@
$('body').append($main);

function section (title) {
return $('<section>').addClass('ins-section').append($('<header>').addClass('ins-section-header').text(title));
return $('<section>')
.addClass('ins-section')
.append($('<header>').addClass('ins-section-header').text(title));
}

function searchItem (icon, title, slug, preview, url) {
@@ -21,10 +23,14 @@
.append(
$('<header>')
.append($('<i>').addClass('fa').addClass(`fa-${icon}`))
.append(title !== null && title !== '' ? title : TRANSLATION['UNTITLED'])
.append(
title !== null && title !== '' ? title : TRANSLATION['UNTITLED']
)
.append(slug ? $('<span>').addClass('ins-slug').text(slug) : null)
)
.append(preview ? $('<p>').addClass('ins-search-preview').text(preview) : null)
.append(
preview ? $('<p>').addClass('ins-search-preview').text(preview) : null
)
.attr('data-url', url);
}

@@ -37,11 +43,21 @@
case 'PAGES':
$searchItems = array.map((
{ title, text, path } // Use config.root instead of permalink to fix url issue
) => searchItem('file', title, null, text.slice(0, 150), ROOT_URL + path));
) =>
searchItem('file', title, null, text.slice(0, 150), ROOT_URL + path)
);
break;
case 'CATEGORIES':
case 'TAGS':
$searchItems = array.map(({ name, slug, permalink }) => searchItem(type === 'CATEGORIES' ? 'folder' : 'tag', name, slug, null, permalink));
$searchItems = array.map(({ name, slug, permalink }) =>
searchItem(
type === 'CATEGORIES' ? 'folder' : 'tag',
name,
slug,
null,
permalink
)
);
break;
default:
return null;
@@ -67,7 +83,10 @@
}

function parseKeywords (keywords) {
return keywords.split(' ').filter(keyword => !!keyword).map(keyword => keyword.toUpperCase());
return keywords
.split(' ')
.filter(keyword => !!keyword)
.map(keyword => keyword.toUpperCase());
}

/**
@@ -150,10 +169,22 @@
const tags = extractToSet(json, 'tags');
const categories = extractToSet(json, 'categories');
return {
posts : posts.filter(FILTERS.POST).sort((a, b) => WEIGHTS.POST(b) - WEIGHTS.POST(a)).slice(0, 5),
pages : pages.filter(FILTERS.PAGE).sort((a, b) => WEIGHTS.PAGE(b) - WEIGHTS.PAGE(a)).slice(0, 5),
categories: categories.filter(FILTERS.CATEGORY).sort((a, b) => WEIGHTS.CATEGORY(b) - WEIGHTS.CATEGORY(a)).slice(0, 5),
tags : tags.filter(FILTERS.TAG).sort((a, b) => WEIGHTS.TAG(b) - WEIGHTS.TAG(a)).slice(0, 5),
posts: posts
.filter(FILTERS.POST)
.sort((a, b) => WEIGHTS.POST(b) - WEIGHTS.POST(a))
.slice(0, 5),
pages: pages
.filter(FILTERS.PAGE)
.sort((a, b) => WEIGHTS.PAGE(b) - WEIGHTS.PAGE(a))
.slice(0, 5),
categories: categories
.filter(FILTERS.CATEGORY)
.sort((a, b) => WEIGHTS.CATEGORY(b) - WEIGHTS.CATEGORY(a))
.slice(0, 5),
tags: tags
.filter(FILTERS.TAG)
.sort((a, b) => WEIGHTS.TAG(b) - WEIGHTS.TAG(a))
.slice(0, 5),
};
}



+ 3
- 1
source/js/main.js View File

@@ -6,7 +6,9 @@
if (this.alt) {
$(this).after(`<span class="caption">${this.alt}</span>`);
}
$(this).wrap(`<a href="${this.src}" title="${this.alt}" class="gallery-item"></a>`);
$(this).wrap(
`<a href="${this.src}" title="${this.alt}" class="gallery-item"></a>`
);
});
});
let options = {


+ 9
- 2
source/js/share.js View File

@@ -1,6 +1,9 @@
($ => {
// Prevent duplicate binding
if (typeof __SHARE_BUTTON_BINDED__ === 'undefined' || !__SHARE_BUTTON_BINDED__) {
if (
typeof __SHARE_BUTTON_BINDED__ === 'undefined' ||
!__SHARE_BUTTON_BINDED__
) {
__SHARE_BUTTON_BINDED__ = true;
} else {
return;
@@ -61,6 +64,10 @@
e.preventDefault();
e.stopPropagation();

window.open(this.href, `article-share-box-window-${Date.now()}`, 'width=500,height=450');
window.open(
this.href,
`article-share-box-window-${Date.now()}`,
'width=500,height=450'
);
});
})(jQuery);

Loading…
Cancel
Save