mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
not found page, contacts
This commit is contained in:
parent
3995a64db1
commit
d7819fd25f
4 changed files with 77 additions and 1 deletions
36
app.rb
36
app.rb
|
@ -12,6 +12,10 @@ before do
|
||||||
redirect '/' if request.post? && !csrf_safe?
|
redirect '/' if request.post? && !csrf_safe?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
not_found do
|
||||||
|
slim :'not_found'
|
||||||
|
end
|
||||||
|
|
||||||
get '/?' do
|
get '/?' do
|
||||||
dashboard_if_signed_in
|
dashboard_if_signed_in
|
||||||
slim :index
|
slim :index
|
||||||
|
@ -418,6 +422,38 @@ get '/password_reset_confirm' do
|
||||||
redirect '/'
|
redirect '/'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get '/contact' do
|
||||||
|
slim :'contact'
|
||||||
|
end
|
||||||
|
|
||||||
|
post '/contact' do
|
||||||
|
|
||||||
|
@errors = []
|
||||||
|
|
||||||
|
if params[:email].empty? || params[:subject].empty? || params[:body].empty?
|
||||||
|
@errors << 'Please fill out all fields'
|
||||||
|
end
|
||||||
|
|
||||||
|
if !recaptcha_valid?
|
||||||
|
@errors << 'Captcha was not filled out (or was filled out incorrectly)'
|
||||||
|
end
|
||||||
|
|
||||||
|
if !@errors.empty?
|
||||||
|
slim :'contact'
|
||||||
|
else
|
||||||
|
EmailWorker.perform_async({
|
||||||
|
from: 'web@neocities.org',
|
||||||
|
replyto: params[:email],
|
||||||
|
to: 'contact@neocities.org',
|
||||||
|
subject: "[NeoCities] Contact: #{params[:subject]}",
|
||||||
|
body: params[:body]
|
||||||
|
})
|
||||||
|
|
||||||
|
flash[:success] = 'Your contact has been sent.'
|
||||||
|
redirect '/'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def require_admin
|
def require_admin
|
||||||
redirect '/' unless signed_in? && current_site.is_admin
|
redirect '/' unless signed_in? && current_site.is_admin
|
||||||
end
|
end
|
||||||
|
|
|
@ -52,6 +52,6 @@
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
h3 Sponsorships, press, speaking invites, general inquiries:
|
h3 Sponsorships, press, speaking invites, general inquiries:
|
||||||
h3: a href="mailto:kyledrake@gmail.com" Contact Me Directly
|
h3: a href="/contact" Contact Me Directly
|
||||||
|
|
||||||
h4 style="margin-top: 30px; margin-bottom: 30px" Thanks. You are great! Now go and make an awesome web site!
|
h4 style="margin-top: 30px; margin-bottom: 30px" Thanks. You are great! Now go and make an awesome web site!
|
||||||
|
|
33
views/contact.slim
Normal file
33
views/contact.slim
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
javascript:
|
||||||
|
var RecaptchaOptions = {
|
||||||
|
theme : 'clean'
|
||||||
|
};
|
||||||
|
|
||||||
|
- if !@errors.empty?
|
||||||
|
.row
|
||||||
|
.span8.offset2
|
||||||
|
.alert.alert-block.alert-error
|
||||||
|
- @errors.each do |error|
|
||||||
|
p = error
|
||||||
|
|
||||||
|
.row
|
||||||
|
.span8.offset2
|
||||||
|
h2 style="margin-bottom: 20px" Contact Us
|
||||||
|
|
||||||
|
form action="/contact" method="POST"
|
||||||
|
input name="csrf_token" type="hidden" value="#{csrf_token}"
|
||||||
|
|
||||||
|
label Email address
|
||||||
|
input type="email" name="email" placeholder="Your Email" style="width: 300px" value="#{params[:email]}"
|
||||||
|
|
||||||
|
label Subject
|
||||||
|
input type="text" name="subject" placeholder="Subject" style="width: 400px" value="#{params[:subject]}"
|
||||||
|
|
||||||
|
label Comments
|
||||||
|
textarea name="body" style="width: 600px" rows="10" #{params[:body]}
|
||||||
|
|
||||||
|
label Fill out captcha so we know you're not a robot
|
||||||
|
== recaptcha_tag :challenge, ssl: true
|
||||||
|
|
||||||
|
div style="margin-top: 30px; margin-bottom: 50px"
|
||||||
|
input.btn.btn-large.btn-success type="submit" value="Send"
|
7
views/not_found.slim
Normal file
7
views/not_found.slim
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
.row
|
||||||
|
.span8.offset2.text-center
|
||||||
|
h2 Not Found
|
||||||
|
h4 We could not find the requested page. Our apologies.
|
||||||
|
h5 It you believe this to be in error, please <a href="/contact">contact us</a> and report the problem. Thank you!
|
||||||
|
- if request.referer
|
||||||
|
a href="#{request.referer}" Go Back
|
Loading…
Add table
Reference in a new issue