Skip to content

Commit

Permalink
add app folder, split project into parts
Browse files Browse the repository at this point in the history
  • Loading branch information
kerpekri committed Sep 7, 2017
1 parent 03cdaa5 commit 53f68a0
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 57 deletions.
12 changes: 8 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ source 'https://rubygems.org'

# framework
gem 'sinatra'

# web server
gem 'thin'
gem 'haml'

gem 'pry'

gem 'haml'
group :development do
gem 'pry'
gem 'rerun'
end

gem 'rerun'
group :production do
#
end
32 changes: 3 additions & 29 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,6 @@
require 'json'
require 'pry'

get '/' do
haml :'home_section/index'
end

get '/choose_letters_or_numbers' do
template = (@params[:type] == 'load_letter_section') ? :'choose_section/picked_letters' : :'choose_section/picked_numbers'

if (request.xhr?)
haml template, :layout => false
else
redirect "/"
end
end

get '/load_button' do
if (request.xhr?)
haml :'choose_section/load_button', :layout => false
else
redirect "/"
end
end

get '/load_generate_section' do
if (request.xhr?)
haml :'generate_section/load_generate_section', :layout => false
else
redirect "/"
end
end
Dir["./app/models/*.rb"].each { |file| require file }
Dir["./app/helpers/*.rb"].each { |file| require file }
Dir["./app/controllers/*.rb"].each { |file| require file }
25 changes: 25 additions & 0 deletions app/controllers/choose_section.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
get '/load_button' do
if (request.xhr?)
haml :'choose_section/load_button', :layout => false
else
redirect "/"
end
end

get '/load_generate_section' do
if @params[:type] == 'lv'
alphabet_list = ''
elsif @params[:type] == 'ru'
alphabet_list = ''
elsif @params[:type] == 'dk'
alphabet_list = ''
else
alphabet_list = ''
end

if (request.xhr?)
haml :'generate_section/load_generate_section', :layout => false
else
redirect "/"
end
end
13 changes: 13 additions & 0 deletions app/controllers/index.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
get '/' do
haml :'home_section/index'
end

get '/choose_letters_or_numbers' do
template = (@params[:type] == 'load_letter_section') ? :'choose_section/picked_letters' : :'choose_section/picked_numbers'

if (request.xhr?)
haml template, :layout => false
else
redirect "/"
end
end
8 changes: 8 additions & 0 deletions app/helpers/app_helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
helpers do
#<% if session[:flash] %>
# <p><%= show_flash(:flash) %></p>
#<% end %>
def helloworld
"helloworld!"
end
end
40 changes: 21 additions & 19 deletions public/js/app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
$(function () {
var enablePageScroll = false;
var alphabetType;

$('#fullpage').fullpage({
anchors: ['firstPage', 'secondPage', 'thirdPage'],
anchors: ['homeSection', 'chooseSection', 'generateSection'],
onLeave: function(index, nextIndex, direction){
if(nextIndex == 2 && (enablePageScroll == false)){
return false;
Expand All @@ -20,7 +21,7 @@ $(function () {

loadTemplate(section_type);
enablePageScroll = true;
$('#section1').removeClass('hide');
$('#choose_section').removeClass('hide');
$.fn.fullpage.moveTo(2);
})

Expand All @@ -33,7 +34,7 @@ $(function () {
type: "GET",
dataType : "html",
success: function (html) {
$("#section1").html("").append(html);
$("#choose_section").html("").append(html);
}
})
.fail(function(xhr, status, errorThrown) {
Expand All @@ -47,7 +48,7 @@ $(function () {
}

function getValueFromSelectOnChange() {
var alphabetType = $("#single option:selected").val();
alphabetType = $("#single option:selected").val();
if (alphabetType) {
loadGenerateButton();
}
Expand All @@ -73,22 +74,23 @@ $(function () {
function initializeMaterializeSelect() {
$('select').material_select();
}
// TODO
$("#generate_loading, #load_button").click(function(){
alert('xxx');
//loadThirdSection();
//$('#section2').removeClass('hide');
//$.fn.fullpage.moveTo(3);
})

function loadThirdSection() {
$('body').on('click','#move_to_generate_section',function(){
loadGenerateSection();
$('#generate_section').removeClass('hide');
$.fn.fullpage.moveTo(3);
});

function loadGenerateSection() {
$.ajax({
url: '/load_third_section',
data: {},
url: '/load_generate_section',
data: {
'alphabet_type': alphabetType
},
type: "GET",
dataType : "html",
success: function (html) {
$("#section2").html("").append(html);
$("#generate_section").html("").append(html);
}
})
.fail(function(xhr, status, errorThrown) {
Expand Down Expand Up @@ -117,13 +119,13 @@ $(function () {
});


function setCookie() {
/*function setCookie() {
Cookies.set('alphabetApp', 'visited', {expires: 0.1, path: ''});
}
}*/

function getCookie() {
/*function getCookie() {
return Cookies.get('alphabetApp');
}
}*/

function insert_letter(random_letter) {
var bodyTitle = $('h2#body_title');
Expand Down
2 changes: 1 addition & 1 deletion views/choose_section/load_button.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
%a.waves-effect.waves-light.btn-large#generate_loading
%a.waves-effect.waves-light.btn-large#move_to_generate_section
%i.material-icons.left> cloud
Generate
2 changes: 1 addition & 1 deletion views/generate_section/load_generate_section.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.container
.row
.col.s10.m8.l4.offset-s1.offset-m2.offset-l4.center_element
%h2#body_title A
%h2#generate_word_section
.row
.col.s6.m8.l4.offset-s3.offset-m2.offset-l4.center_element
%button#rotation_arrow{:click_id => "rotation_arrow", :type => "submit"}
Expand Down
6 changes: 3 additions & 3 deletions views/home_section/index.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.container#fullpage
.row#section0.section
.row#home_section.section
.col.s12
%h1 Hi there, what kind of beautifull things you want to generate?
.col.s6
Expand All @@ -10,5 +10,5 @@
%a.waves-effect.waves-light.btn-large#load_number_section
%i.material-icons.left> cloud
Numbers
.row#section1.section.hide{"data-anchor" => "slide1"}
.row#section2.section.hide{"data-anchor" => "slide2"}
.row#choose_section.section.hide
.row#generate_section.section.hide

0 comments on commit 53f68a0

Please sign in to comment.