diff options
Diffstat (limited to 'app/views')
23 files changed, 295 insertions, 0 deletions
| diff --git a/app/views/admin/dashboard/index.html.erb b/app/views/admin/dashboard/index.html.erb new file mode 100644 index 0000000..30cf866 --- /dev/null +++ b/app/views/admin/dashboard/index.html.erb @@ -0,0 +1,10 @@ +<h1>Administrateur</h1> + +<!-- <h2>Tartiflettes</h2> --> + +<p> +    <%= button_to "Déconnexion", +		  session_path(session), +		  method: :delete %> +</p> +<p><%= link_to "Télécharger tous les scores en format CSV", admin_scores_export_path %></p> diff --git a/app/views/admin/dashboard/tmp b/app/views/admin/dashboard/tmp new file mode 100644 index 0000000..986fc28 --- /dev/null +++ b/app/views/admin/dashboard/tmp @@ -0,0 +1,19 @@ +<% ScoringCriterium.grouped_by_category.each do |category, criteria| %> +    <h3><%= category.capitalize %></h3> +    <table> +	<thead> +	    <tr> +		<th>Numéro</th> +		<th>Score</th> +	    </tr> +	</thead> +	<tbody> +	    <% @tartiflettes.each do |tartiflette| %> +		<tr> +		    <td><%= tartiflette.scoring_id %></td> +		    <td><%= tartiflette.scores.where(&:scoring_criterium.include? criteria) %></td> +		</tr> +	    <% end %> +	</tbody> +    </table> +<% end %> diff --git a/app/views/home/_code_of_honor.html.erb b/app/views/home/_code_of_honor.html.erb new file mode 100644 index 0000000..517a73e --- /dev/null +++ b/app/views/home/_code_of_honor.html.erb @@ -0,0 +1,14 @@ +<div id="code-of-honor" class="<%= session[:agreed_to_code_of_honor] ? 'accepted' : 'rejected' %>"> +    <h2>Code d'honneur</h2> +    <p> +	Tout Tartifleur s'engage à voter dans le respect de la +	tradition de la WTT. Il ou elle se doit de voter en toute +	honnêteté intellectuelle afin de favoriser un résultat mérité +	! +    </p> +    <% if session[:agreed_to_code_of_honor] %> +	<%= button_to "Renéguer", toggle_code_of_honor_path %> +    <% else %> +	<%= button_to "Accepter", toggle_code_of_honor_path %> +    <% end %> +</div> diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb new file mode 100644 index 0000000..ca8f3a3 --- /dev/null +++ b/app/views/home/index.html.erb @@ -0,0 +1,42 @@ +<h1>World Tartiflette Tour 2024</h1> + +<%= image_tag("blason_Savoie.png", :alt => "blason de la Savoie", id: "blason", width: 80) %> + +<%= render "code_of_honor" %> + +<h2>Noter les Tartiflettes</h2> +<ul> +    <% @tartiflettes.each do |tartiflette| %> +	<li><%= tartiflette.scoring_id %> +	    <% if session[:agreed_to_code_of_honor] %> +		<% if TartifletteScoringService.scored?(tartiflette, session) %> +		    <%= link_to "modifier", tartiflette_edit_scores_path(tartiflette) %> +		<% else %> +		    <%= link_to "noter", new_tartiflette_score_path(tartiflette) %> +		<% end %> +	    <% end %> +	</li> +    <% end %> +</ul> +<!--  +     <h2>Résultats</h2> +     <table> +     <thead> +     <tr> +     <th>Tartiflette</th> +     <th>Points</th> +     </tr> +     </thead> +     <tbody> +     <% TartifletteScoringService.leaderboard.each do |tartiflette, total_score| %> +     <tr> +     <td><%= tartiflette.scoring_id %></td> +     <td><%= total_score %></td> +     </tr> +     <% end %> +     </tbody> +     </table> +--> +<p> +    <%= link_to "Admin", admin_dashboard_path %> +</p> diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb new file mode 100644 index 0000000..bba04fb --- /dev/null +++ b/app/views/layouts/_footer.html.erb @@ -0,0 +1,3 @@ +<footer> +    <p>© <%= Date.current.year %> World Tartiflette Tour</p> +</footer> diff --git a/app/views/layouts/_notifications.html.erb b/app/views/layouts/_notifications.html.erb new file mode 100644 index 0000000..3e1eb83 --- /dev/null +++ b/app/views/layouts/_notifications.html.erb @@ -0,0 +1,8 @@ +<div id="notifications"> +    <% if alert %> +	<p class="alert"><%= alert %></p> +    <% end %> +    <% if notice %> +	<p class="notice"><%= notice %></p> +    <% end %> +</div> diff --git a/app/views/layouts/_topnav.html.erb b/app/views/layouts/_topnav.html.erb new file mode 100644 index 0000000..f93ed99 --- /dev/null +++ b/app/views/layouts/_topnav.html.erb @@ -0,0 +1,5 @@ +<nav id="top"> +    <ul> +	<li><%= link_to "Accueil", root_path %></li> +    </ul> +</nav> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb new file mode 100644 index 0000000..680dec1 --- /dev/null +++ b/app/views/layouts/application.html.erb @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<html> +    <head> +	<title><%= content_for(:title) || "WTT" %></title> +	<meta name="viewport" content="width=device-width,initial-scale=1"> +	<meta name="apple-mobile-web-app-capable" content="yes"> +	<meta name="mobile-web-app-capable" content="yes"> +	<%= csrf_meta_tags %> +	<%= csp_meta_tag %> + +	<%= yield :head %> + +	<%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %> +	<%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %> + +	<%= favicon_link_tag "blason_Savoie.png" %> +	<!-- <link rel="icon" href="/icon.png" type="image/png"> +	     <link rel="icon" href="/icon.svg" type="image/svg+xml"> +	     <link rel="apple-touch-icon" href="/icon.png"> --> + +	<%# Includes all stylesheet files in app/assets/stylesheets %> +	<%= stylesheet_link_tag :app, "data-turbo-track": "reload" %> +    </head> + +    <body> +	<%= render "layouts/topnav" %> +	<%= render "layouts/notifications" %> +	<main> +	    <%= yield %> +	</main> +	<%= render "layouts/footer" %> +    </body> +</html> diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..3aac900 --- /dev/null +++ b/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<html> +  <head> +    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> +    <style> +      /* Email styles need to be inline */ +    </style> +  </head> + +  <body> +    <%= yield %> +  </body> +</html> diff --git a/app/views/layouts/mailer.text.erb b/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/app/views/passwords/edit.html.erb b/app/views/passwords/edit.html.erb new file mode 100644 index 0000000..9f0c87c --- /dev/null +++ b/app/views/passwords/edit.html.erb @@ -0,0 +1,9 @@ +<h1>Update your password</h1> + +<%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %> + +<%= form_with url: password_path(params[:token]), method: :put do |form| %> +  <%= form.password_field :password, required: true, autocomplete: "new-password", placeholder: "Enter new password", maxlength: 72 %><br> +  <%= form.password_field :password_confirmation, required: true, autocomplete: "new-password", placeholder: "Repeat new password", maxlength: 72 %><br> +  <%= form.submit "Save" %> +<% end %> diff --git a/app/views/passwords/new.html.erb b/app/views/passwords/new.html.erb new file mode 100644 index 0000000..44efb2b --- /dev/null +++ b/app/views/passwords/new.html.erb @@ -0,0 +1,8 @@ +<h1>Forgot your password?</h1> + +<%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %> + +<%= form_with url: passwords_path do |form| %> +  <%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder: "Enter your email address", value: params[:email_address] %><br> +  <%= form.submit "Email reset instructions" %> +<% end %> diff --git a/app/views/passwords_mailer/reset.html.erb b/app/views/passwords_mailer/reset.html.erb new file mode 100644 index 0000000..4a06619 --- /dev/null +++ b/app/views/passwords_mailer/reset.html.erb @@ -0,0 +1,4 @@ +<p> +  You can reset your password within the next 15 minutes on +  <%= link_to "this password reset page", edit_password_url(@user.password_reset_token) %>. +</p> diff --git a/app/views/passwords_mailer/reset.text.erb b/app/views/passwords_mailer/reset.text.erb new file mode 100644 index 0000000..2cf03fc --- /dev/null +++ b/app/views/passwords_mailer/reset.text.erb @@ -0,0 +1,2 @@ +You can reset your password within the next 15 minutes on this password reset page: +<%= edit_password_url(@user.password_reset_token) %> diff --git a/app/views/pwa/manifest.json.erb b/app/views/pwa/manifest.json.erb new file mode 100644 index 0000000..883d71c --- /dev/null +++ b/app/views/pwa/manifest.json.erb @@ -0,0 +1,22 @@ +{ +  "name": "Wtt", +  "icons": [ +    { +      "src": "/icon.png", +      "type": "image/png", +      "sizes": "512x512" +    }, +    { +      "src": "/icon.png", +      "type": "image/png", +      "sizes": "512x512", +      "purpose": "maskable" +    } +  ], +  "start_url": "/", +  "display": "standalone", +  "scope": "/", +  "description": "Wtt.", +  "theme_color": "red", +  "background_color": "red" +} diff --git a/app/views/pwa/service-worker.js b/app/views/pwa/service-worker.js new file mode 100644 index 0000000..b3a13fb --- /dev/null +++ b/app/views/pwa/service-worker.js @@ -0,0 +1,26 @@ +// Add a service worker for processing Web Push notifications: +// +// self.addEventListener("push", async (event) => { +//   const { title, options } = await event.data.json() +//   event.waitUntil(self.registration.showNotification(title, options)) +// }) +// +// self.addEventListener("notificationclick", function(event) { +//   event.notification.close() +//   event.waitUntil( +//     clients.matchAll({ type: "window" }).then((clientList) => { +//       for (let i = 0; i < clientList.length; i++) { +//         let client = clientList[i] +//         let clientPath = (new URL(client.url)).pathname +// +//         if (clientPath == event.notification.data.path && "focus" in client) { +//           return client.focus() +//         } +//       } +// +//       if (clients.openWindow) { +//         return clients.openWindow(event.notification.data.path) +//       } +//     }) +//   ) +// }) diff --git a/app/views/registrations/new.html.erb b/app/views/registrations/new.html.erb new file mode 100644 index 0000000..9d9f9bc --- /dev/null +++ b/app/views/registrations/new.html.erb @@ -0,0 +1,17 @@ +<h1>Sign Up</h1> + +<%= form_with model: @user, url: registration_path, method: :post, local: true do |f| %> +    <div> +	<%= f.label :email_address %> +	<%= f.email_field :email_address, required: true %> +    </div> +    <div> +	<%= f.label :password %> +	<%= f.password_field :password, required: true %> +    </div> +    <div> +	<%= f.label :password_confirmation %> +	<%= f.password_field :password_confirmation, required: true %> +    </div> +    <%= f.submit "Sign Up" %> +<% end %> diff --git a/app/views/scores/_form.html.erb b/app/views/scores/_form.html.erb new file mode 100644 index 0000000..9cbcec7 --- /dev/null +++ b/app/views/scores/_form.html.erb @@ -0,0 +1,19 @@ +<%= form_with url: form_url, method: form_method, local: true do |f| %> +    <% ScoringCriterium.grouped_by_category.each do |category, criteria| %> +	<fieldset> +	    <legend><%= category.titlecase %></legend> +	    <% criteria.each do |criterium| %> +		<% current_score = existing_scores.find { |score| score.scoring_criterium_id == criterium.id } %> +		<p> +		    <%= select_tag "scores[#{criterium.id}][value]", +				   options_for_select(1..5, current_score&.value), +				   required: true, +				   prompt: "Score" %> +		    <%= label_tag "scores[#{criterium.id}][value]", +				  criterium.name.capitalize %> +		</p> +	    <% end %> +	</fieldset> +    <% end %> +    <%= f.submit submit_text %> +<% end %> diff --git a/app/views/scores/edit_all.html.erb b/app/views/scores/edit_all.html.erb new file mode 100644 index 0000000..2be7149 --- /dev/null +++ b/app/views/scores/edit_all.html.erb @@ -0,0 +1,7 @@ +<h1>Modifier les Notes pour la Tartiflette nº<%= @tartiflette.scoring_id %></h1> + +<%= render "form", +	   form_url: tartiflette_update_scores_path(@tartiflette), +           form_method: :patch, +           existing_scores: @scores, +           submit_text: "Mettre à jour mes scores" %> diff --git a/app/views/scores/new.html.erb b/app/views/scores/new.html.erb new file mode 100644 index 0000000..cf171cc --- /dev/null +++ b/app/views/scores/new.html.erb @@ -0,0 +1,7 @@ +<h1>Noter la Tartiflette nº<%= @tartiflette.scoring_id %></h1> + +<%= render "form", +	   form_url: tartiflette_scores_path(@tartiflette), +           form_method: :post, +           existing_scores: [], +           submit_text: "Envoyer mes scores" %> diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb new file mode 100644 index 0000000..51029b1 --- /dev/null +++ b/app/views/sessions/new.html.erb @@ -0,0 +1,20 @@ +<%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %> +<%= tag.div(flash[:notice], style: "color:green") if flash[:notice] %> + +<%= form_with url: session_path do |form| %> +    <%= form.email_field :email_address, +    required: true, +    autofocus: true, +    autocomplete: "username", +    placeholder: "Enter your email address", +    value: params[:email_address] %><br> +    <%= form.password_field :password, +    required: true, +    autocomplete: "current-password", +    placeholder: "Enter your password", +    maxlength: 72 %><br> +    <%= form.submit "Sign in" %> +<% end %> +<br> + +<%= link_to "Forgot password?", new_password_path %> diff --git a/app/views/tartiflettes/index.html.erb b/app/views/tartiflettes/index.html.erb new file mode 100644 index 0000000..09b2748 --- /dev/null +++ b/app/views/tartiflettes/index.html.erb @@ -0,0 +1,3 @@ +<h1>Tartiflettes</h1> + +<p>Toutes les tartiflettes</p> diff --git a/app/views/tartiflettes/show.html.erb b/app/views/tartiflettes/show.html.erb new file mode 100644 index 0000000..3753604 --- /dev/null +++ b/app/views/tartiflettes/show.html.erb @@ -0,0 +1,3 @@ +<h1>Tartiflette nº<%= @tartiflette.scoring_id %></h1> + +<p>Scores obtenus pour une tartiflette donnée.</p> | 
