Преглед изворни кода

Project notes and images. Better routing. 404 error pages.

Iñigo Valentin пре 4 година
родитељ
комит
4de727a4ad
49 измењених фајлова са 655 додато и 270 уклоњено
  1. 5 3
      .gitignore
  2. 1 0
      Gemfile
  3. 1 0
      Gemfile.lock
  4. 48 0
      app/assets/javascripts/project.js
  5. 50 0
      app/assets/stylesheets/error.css
  6. 1 1
      app/assets/stylesheets/profile.css
  7. 16 5
      app/assets/stylesheets/project.css
  8. 4 0
      app/assets/stylesheets/ui.css
  9. 9 0
      app/controllers/application_controller.rb
  10. 5 0
      app/controllers/error_controller.rb
  11. 8 0
      app/controllers/projects_controller.rb
  12. 2 0
      app/helpers/error_helper.rb
  13. 0 4
      app/mailers/application_mailer.rb
  14. 4 0
      app/models/project.rb
  15. 0 6
      app/models/tag.rb
  16. 1 1
      app/models/text.rb
  17. 31 0
      app/views/error/error_404.html.erb
  18. 81 2
      app/views/projects/show.html.erb
  19. 4 5
      config/application.rb
  20. 19 0
      config/credentials/credentials.example
  21. 51 0
      config/database.yml
  22. 1 1
      config/environment.rb
  23. 1 1
      config/environments/development.rb
  24. 2 0
      config/locales/en.yml
  25. 2 1
      config/locales/es.yml
  26. 2 0
      config/locales/eu.yml
  27. 22 3
      config/routes.rb
  28. 0 18
      db/migrate/20211208235937_create_projects.rb
  29. 0 36
      db/migrate/20211209144738_create_active_storage_tables.active_storage.rb
  30. 0 20
      db/migrate/20211209155645_create_users.rb
  31. 0 12
      db/migrate/20211209161003_create_mail_adresses.rb
  32. 0 12
      db/migrate/20211209221626_create_texts.rb
  33. 0 10
      db/migrate/20211210121307_create_technologies.rb
  34. 0 8
      db/migrate/20211210121633_create_users_technologies_join_table.rb
  35. 0 5
      db/migrate/20211210122542_add_fieldname_to_technologies_users.rb
  36. 0 8
      db/migrate/20211210122634_create_projects_technologies_join_table.rb
  37. 0 5
      db/migrate/20211210122749_add_fieldname_to_projects_technologies.rb
  38. 0 10
      db/migrate/20211210124959_create_tags.rb
  39. 0 10
      db/migrate/20211211222327_create_url_targets.rb
  40. 0 11
      db/migrate/20211211231839_create_project_url.rb
  41. 0 10
      db/migrate/20211212113709_create_licenses.rb
  42. 0 12
      db/migrate/20211213092427_create_social_links.rb
  43. 0 12
      db/migrate/20211213094550_create_user_social_links.rb
  44. 0 13
      db/migrate/20211213105552_create_resumes.rb
  45. 0 15
      db/migrate/20211228133200_create_messages.rb
  46. 12 10
      db/schema.rb
  47. 265 0
      db/seeds.rb
  48. BIN
      public/fonts/Handwritten.ttf
  49. 7 0
      test/controllers/error_controller_test.rb

+ 5 - 3
.gitignore

@@ -37,6 +37,8 @@ yarn-debug.log*
 .project
 .custom-data
 
-/config/credentials/development.key
-
-/config/credentials/production.key
+# Credentials and keys
+/config/credentials/*.key
+/config/credentials/*.yml.enc
+/config/credentials.yml.enc
+/config/master.key

+ 1 - 0
Gemfile

@@ -30,6 +30,7 @@ gem 'bootsnap', '>= 1.4.4', require: false
 
 gem 'turbolinks_render'
 
+gem 'loofah', '>= 2.12.0'
 
 group :development, :test do
   # Call 'byebug' anywhere in the code to stop execution and get a debugger console

+ 1 - 0
Gemfile.lock

@@ -214,6 +214,7 @@ DEPENDENCIES
   capybara (>= 3.26)
   jbuilder (~> 2.7)
   listen (~> 3.3)
+  loofah (>= 2.12.0)
   mysql2 (~> 0.5)
   puma (~> 5.0)
   rails (~> 6.1.4, >= 6.1.4.1)

+ 48 - 0
app/assets/javascripts/project.js

@@ -0,0 +1,48 @@
+// Populate this array as teh pages are loaded
+var images = [];
+selectedPhoto = 0;
+
+var galleryOpen = false;
+function closeGallery(){
+    document.getElementById('gallery_bg').style.opacity = "0.0";
+    document.getElementById('gallery_bg').style.display = "none";
+    document.getElementById('gallery').style.display = "none";
+    galleryOpen = false;
+}
+
+function showImage(index){
+    if (galleryOpen === false){
+        openGallery();
+    }
+    document.getElementById('gallery_image').src = images[index];
+    selectedPhoto = index;
+    var previews = document.getElementsByClassName('gallery_preview');
+    for (i = 0; i < previews.length; i ++){
+        previews[i].classList.remove('gallery_preview_selected');
+    }
+    document.getElementById('gallery_preview_' + index).classList.add('gallery_preview_selected')
+}
+
+
+function openGallery(){
+    document.getElementById('gallery_bg').style.opacity = "0.6";
+    document.getElementById('gallery_bg').style.display = "block";
+    document.getElementById('gallery').style.display = "block";
+    galleryOpen = true;
+}
+
+function previousPhoto(){
+    newIndex = selectedPhoto - 1;
+    if (newIndex < 0){
+        newIndex = images.length - 1;
+    }
+    showImage(newIndex);
+}
+
+function nextPhoto(){
+    newIndex = selectedPhoto + 1;
+    if (newIndex >= images.length){
+        newIndex = 0;
+    }
+    showImage(newIndex);
+}

+ 50 - 0
app/assets/stylesheets/error.css

@@ -0,0 +1,50 @@
+section{
+    margin: auto;
+    max-width: 60em;
+    border: 0.1em solid #330000;
+}
+
+section h3{
+    color: #ffffff;
+    background-color: #ef3939;
+    border-bottom: 0.1em solid #330000;
+}
+
+section div#left{
+    display: inline-block;
+    vertical-align: middle;
+    width: 15em;
+    height: 6em;
+    margin: 2em;
+    padding-top: 2em;
+    background-color: #ef3939;
+    color: #ffffff;
+    font-weight: bold;
+    border: 0.3em solid #330000;
+    border-radius: 0.5em;
+    text-align: center;
+    text-shadow: 0 0 0.1em #000000;
+    box-shadow: 0 0 0.2em #ef3939;
+}
+section div#left p{
+    display: inline-block;
+    vertical-align: middle;
+    font-weight: bold;
+    font-size: 150%;
+    margin: 0.2em;
+}
+section div#left p#code{
+    font-size: 300%;
+}
+section div#left p span{
+    display: block;
+}
+
+section div#right{
+    display: inline-block;
+    vertical-align: middle;
+    margin: 1.5em 1em 1.5em 0;
+    padding-left: 2em;
+    max-width: 35em;
+    border-left: 0.2em solid #444444
+}

+ 1 - 1
app/assets/stylesheets/profile.css

@@ -123,4 +123,4 @@ section#about div#resume_download details summary{
 section#about div#resume_download details ul{
     text-align: left;
     margin: 0.1em 0.1em 0.1em 0.1em;
-}
+}

Разлика између датотеке није приказан због своје велике величине
+ 16 - 5
app/assets/stylesheets/project.css


+ 4 - 0
app/assets/stylesheets/ui.css

@@ -7,6 +7,10 @@
     font-family: 'Latin'; 
     src:  url('/fonts/Latin-Modern-Mono-Light-Bold.otf');
 }
+@font-face {
+    font-family: 'Handwritten'; 
+    src:  url('/fonts/Handwritten.ttf'); 
+}
 
 /* Elements to be shown only in large screens. */
 .desktop{

+ 9 - 0
app/controllers/application_controller.rb

@@ -1,4 +1,5 @@
 class ApplicationController < ActionController::Base
+    rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found
 
     before_action :set_locale
     before_action :set_user
@@ -20,4 +21,12 @@ class ApplicationController < ActionController::Base
         I18n.available_locales.map(&:to_s).include?(parsed_locale) ? parsed_locale : nil
     end
     
+    def record_not_found(m, *args, &block)
+        Rails.logger.error("MMM" + m)
+        print("\nMETHOD MISSING\n")
+        redirect_to :controller=>"error", :action=>"error_404"
+        # or render/redirect_to somewhere else
+    end
+
+    
 end

+ 5 - 0
app/controllers/error_controller.rb

@@ -0,0 +1,5 @@
+class ErrorController < ApplicationController
+    def error_404
+        print("\nERRORCONTROLLER\n")
+    end
+end

+ 8 - 0
app/controllers/projects_controller.rb

@@ -4,5 +4,13 @@ class ProjectsController < ApplicationController
     end
     def show
         @project = Project.where(permalink: params[:permalink])[0]
+        if @project == nil
+            print("ERROR 404")
+            #render status: 404
+            #redirect_to '/404'
+            respond_to do |format|
+                format.all { render "error/error_404", status: 404}
+              end
+        end
     end
 end

+ 2 - 0
app/helpers/error_helper.rb

@@ -0,0 +1,2 @@
+module ErrorHelper
+end

+ 0 - 4
app/mailers/application_mailer.rb

@@ -5,10 +5,6 @@ class ApplicationMailer < ActionMailer::Base
     def message_email(user, message)
         @message = message
         to = user.mail_adresses[0].address
-        print("SENDING EMAIL\n")
-        print("SENDING TO " + to + "\n")
-        print("DOMAIN TO " + Rails.application.credentials.smtp[:domain] + "\n")
-        print("AUTH " + Rails.application.credentials.smtp[:authentication] + "\n")
         to = Rails.application.credentials.smtp[:username]
         mail(to: to, subject: 'New message')
     end

+ 4 - 0
app/models/project.rb

@@ -3,6 +3,7 @@ class Project < ApplicationRecord
     has_and_belongs_to_many :technologies
     has_many :projectUrls
     belongs_to :license
+    has_many_attached :images
     def i18n_title
         return Text.where(user_id: self.user_id, language: I18n.locale, key: self.title)[0].text
     end
@@ -12,4 +13,7 @@ class Project < ApplicationRecord
     def i18n_text
         return Text.where(user_id: self.user_id, language: I18n.locale, key: self.text)[0].text
     end
+    def i18n_comment
+        return Text.where(user_id: self.user_id, language: I18n.locale, key: self.comment)[0].text
+    end
 end

+ 0 - 6
app/models/tag.rb

@@ -1,6 +0,0 @@
-class Tag < ApplicationRecord
-    belongs_to :project_id
-    def i18n_tag
-        return t(self.tag)
-    end
-end

+ 1 - 1
app/models/text.rb

@@ -1,3 +1,3 @@
 class Text < ApplicationRecord
-    belongs_to :user
+    belongs_to :user, optional: true
 end

+ 31 - 0
app/views/error/error_404.html.erb

@@ -0,0 +1,31 @@
+<% content_for :head do %>
+    <%= stylesheet_link_tag "error", media: "all", "data-turbolinks-track": "reload" %>
+<% end %>
+<section>
+    <h3>
+        <%= t("error.error_404_title" ) %>
+    </h3>
+    <div id='left'>
+        <p id='code'>
+            404
+        </p>
+        <p>
+            <span><%= t("error.error" ) %></span>
+            <span><%= t("error.code" ) %></span>
+        </p>
+    </div>
+    <div id='right'>
+        <h4>
+           <%= t("error.error_404_description" ) %>
+        </h4>
+        <%= t("error.try_solution" ) %>
+        <ul>
+            <li>
+                <a href='javascript: history.go(-1);'><%= t("error.error_400_solution_0") %></a>
+            </li>
+            <li>
+                <a href='/'><%= t("error.error_400_solution_1") %></a>
+            </li>
+        </ul>
+    </div>
+</section>

+ 81 - 2
app/views/projects/show.html.erb

@@ -1,5 +1,6 @@
 <% content_for :head do %>
     <%= stylesheet_link_tag "project", media: "all", "data-turbolinks-track": "reload" %>
+    <%= javascript_include_tag "project", "data-turbolinks-track" => true  %>
 <% end %>
 <section>
     <h3>
@@ -10,7 +11,7 @@
             <h4>
                 <%= @project.i18n_header %>
             </h4>
-            <p id='text'>
+            <div id='text'>
                 <% if @project.logo.attached? %>
                     <%=
                         image_tag(
@@ -22,7 +23,15 @@
                     %>
                 <% end %>
                 <%= @project.i18n_text.html_safe %>
-            </p>
+            </div>
+            <% if @project.comment != nil %>
+                <div id='comment'>
+                    <div id='comment_title'>
+                        <%= t("project.comment", name: @user.first_name) %>
+                    </div>
+                    <%= @project.i18n_comment.html_safe %>
+                </div>
+            <% end %>
         </div>
         <div id='info_details'>
             <div id='links' class='details'>
@@ -67,6 +76,76 @@
                     )
                 %>
             </div> <!-- #license -->
+            <% if @project.images.attached? %>
+                <div id='images' class='details'>
+                    <%= t("project.images") %>
+                    <br/>
+                    <% i = 0 %>
+                    <% @project.images.each do |image| %>
+                        <%=
+                            link_to(
+                                image_tag(
+                                    image,
+                                    class: "project_image",
+                                    alt: ""
+                                ),
+                                "javascript:showImage(" + i.to_s + ");"
+                        ) %>
+                        <script>
+                            images[<%= i %>] = '<%= url_for(image) %>';
+                        </script>
+                        <% i = i + 1 %>
+                    <% end %>
+                </div>
+            <% end %>
         </div> <!-- #info_details -->
     </article>
 </section>
+<div id='gallery_bg'>
+</div>
+<section id='gallery'>
+    <h3>
+        <%= @project.i18n_title %>
+        <span id='gallery_close'>
+            <%=
+                link_to(
+                    image_tag(
+                        "control/close.svg", 
+                        id: "gallery_close",
+                        alt: t("contact.cancel")
+                    ),
+                    #"mailto:" + @user.mail_adresses[0].address,
+                    "javascript:closeGallery()"
+                )
+            %>
+        </span>
+    </h3>
+    <article>
+        <div id='gallery_image_container'>
+            <img id='gallery_image'/>
+        </div>
+        <div id='gallery_controls'>
+            <input type='button' value='<' onClick='javascript:previousPhoto();'/>
+            <div id='image_list'>
+                <% i = 0 %>
+                <% @project.images.each do |image| %>
+                    <%=
+                        link_to(
+                            image_tag(
+                                image,
+                                id: "gallery_preview_" + i.to_s,
+                                class: "gallery_preview",
+                                alt: ""
+                            ),
+                            "javascript:showImage(" + i.to_s + ");"
+                    ) %>
+                    <script>
+                        images[<%= i %>] = '<%= url_for(image) %>';
+                    </script>
+                    <% i = i + 1 %>
+                <% end %>
+            </div>
+            <input type='button' value='>' onClick='javascript:nextPhoto();'/>
+        </div>
+    </article>
+</section>

+ 4 - 5
config/application.rb

@@ -28,20 +28,19 @@ module InigoValentin
     
     # Hack for allowing SVG files. While this hack is here, we should **not**
     # allow arbitrary SVG uploads. https://github.com/rails/rails/issues/34665
-    
     ActiveStorage::Engine.config
     .active_storage
     .content_types_to_serve_as_binary
     .delete('image/svg+xml')
-    
+
+    # Serve raw html from assests (for resumes)
     ActiveStorage::Engine.config
     .active_storage
     .content_types_to_serve_as_binary
     .delete('text/html')
-    
     ActiveStorage::Engine.config.active_storage.content_types_allowed_inline.append('text/html')
-    print ActiveStorage::Engine.config.active_storage.content_types_to_serve_as_binary
-    print ActiveStorage::Engine.config.active_storage.content_types_allowed_inline
+    
+    config.exceptions_app = self.routes
     
     config.action_mailer.delivery_method = :smtp
     config.action_mailer.smtp_settings = {

+ 19 - 0
config/credentials/credentials.example

@@ -0,0 +1,19 @@
+# Make your credential files look like this
+
+# Database configuration
+database:
+    name: 'XXXX'
+    user: 'XXXX'
+    password: 'XXXX'
+
+# Mail server configuration
+smtp:
+    server: 'XXXX'
+    port: 0001
+    domain: 'XXXX'
+    username: 'XXXX'
+    password: 'XXXX'
+    authentication: 'login'
+    ssl: true
+    #enable_starttls_auto: true
+    openssl_verify_mode: 'none'

+ 51 - 0
config/database.yml

@@ -0,0 +1,51 @@
+# MySQL. Versions 5.5.8 and up are supported.
+#
+# Install the MySQL driver
+#   gem install mysql2
+#
+# Ensure the MySQL gem is defined in your Gemfile
+#   gem 'mysql2'
+#
+# And be sure to use new-style password hashing:
+#   https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html
+#
+default: &default
+    adapter: mysql2
+    encoding: utf8mb4
+    pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
+    username: <%= Rails.application.credentials.database[:user] %>
+    password: <%= Rails.application.credentials.database[:password] %>
+    database: <%= Rails.application.credentials.database[:name] %>
+    socket: /var/run/mysqld/mysqld.sock
+
+development:
+    <<: *default
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+    <<: *default
+
+# As with config/credentials.yml, you never want to store sensitive information,
+# like your database password, in your source code. If your source code is
+# ever seen by anyone, they now have access to your database.
+#
+# Instead, provide the password or a full connection URL as an environment
+# variable when you boot the app. For example:
+#
+#   DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
+#
+# If the connection URL is provided in the special DATABASE_URL environment
+# variable, Rails will automatically merge its configuration values on top of
+# the values provided in this file. Alternatively, you can specify a connection
+# URL environment variable explicitly:
+#
+#   production:
+#     url: <%= ENV['MY_APP_DATABASE_URL'] %>
+#
+# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
+# for a full overview on how database connection configuration can be specified.
+#
+production:
+    <<: *default

+ 1 - 1
config/environment.rb

@@ -2,4 +2,4 @@
 require_relative "application"
 
 # Initialize the Rails application.
-Rails.application.initialize!
+Rails.application.initialize!

+ 1 - 1
config/environments/development.rb

@@ -12,7 +12,7 @@ Rails.application.configure do
   config.eager_load = false
 
   # Show full error reports.
-  config.consider_all_requests_local = true
+  config.consider_all_requests_local = false
 
   # Enable/disable caching. By default caching is disabled.
   # Run rails dev:cache to toggle caching.

+ 2 - 0
config/locales/en.yml

@@ -150,6 +150,8 @@ en:
         search_license: "License"
         license_summary: "In a few words:"
         search_advanced: "Advanced search"
+        comment: "%{name}'s notes"
+        images: "Image gallery"
     share:
         google: "Google +"
         twitter: "Twitter"

+ 2 - 1
config/locales/es.yml

@@ -150,6 +150,8 @@ es:
         search_license: "Licencia"
         license_summary: "En pocas palabras:"
         search_advanced: "Búsqueda avanzada"
+        comment: "Notas de %{name}"
+        images: "Galería"
     share:
         google: "Google +"
         twitter: "Twitter"
@@ -216,7 +218,6 @@ es:
                        En la mayoría de proyectos encontrarás un apartado sobre la licencia, normalmente una GPL o Creative Commons. Para todo lo demás, se aplica la licencia <a rel='license' target='_blank' href='http://creativecommons.org/licenses/by-sa/4.0/'>Creative Commons Attribution-ShareAlike 4.0 International License</a>.
                        <br/><br/>
                        Lo que significa que puedes usar, modificar, y difundir estos contenidos y sus modificaciones, siempre que me menciones como fuente (por ejemplo, con un enlace a esta página) y mantengas la misma licencia."
-                       
 
 
 

+ 2 - 0
config/locales/eu.yml

@@ -150,6 +150,8 @@ eu:
         search_license: "Licentzia"
         license_summary: "Hitz gutxitan:"
         search_advanced: "Bilaketa aurreratua"
+        comment: "%{name}-ren oharrak"
+        images: "Irudiak"
     share:
         google: "Google +"
         twitter: "Twitter"

+ 22 - 3
config/routes.rb

@@ -2,12 +2,31 @@ Rails.application.routes.draw do
     scope '(:locale)', locale: /#{I18n.available_locales.join('|')}/ do
     end
 
-    root "main#index"
-    get "/:locale", to: "main#index", defaults: { locale: I18n.locale }, as: "main"
+    # Profile page
     get "/:locale/profile", to: "profile#index", defaults: { locale: I18n.locale }, as: "profile"
+    get "/profile/", to: "profile#index", as: "profile_canonical"
+    
+    # Project list
+    get "/projects", to: "projects#index" , as: "projects_canonical"
     get "/:locale/projects", to: "projects#index", defaults: { locale: I18n.locale }, as: "project_index"
+    
+    # Project view
+    get "/projects/:permalink", to: "projects#show", as: "project_canonical"
     get "/:locale/projects/:permalink", to: "projects#show", defaults: { locale: I18n.locale }, as: 'project_show'
+    
+    # Help page
+    get "/help", to: "help#index", as: "help_canonical"
     get "/:locale/help", to: "help#index", defaults: { locale: I18n.locale }, as: 'help'
-    get "/:locale/contact", to: "contact#index", defaults: { locale: I18n.locale }, as: 'contact'
+    
+    # Main page
+    root "main#index"
+    get "/:locale", to: "main#index", defaults: { locale: I18n.locale }, as: "main"
+    
+    # Contact form    
     post "/contact", to: "contact#create", defaults: { locale: I18n.locale }, as: 'contact_create'
+    
+    # Error pages
+    # Redirect to 404, but only for files without extension and content type HTML
+    get '*unmatched_route', :to => 'error#error_404', format: false, constraints: { format: 'text/html' }
+    
 end

+ 0 - 18
db/migrate/20211208235937_create_projects.rb

@@ -1,18 +0,0 @@
-class CreateProjects < ActiveRecord::Migration[6.1]
-  def change
-    create_table :projects do |t|
-      t.string :permalink
-      t.integer :priority
-      t.integer :nature
-      t.string :title
-      t.string :logo
-      t.string :header
-      t.text :text
-      t.references :license, null: false, foreign_key: true
-      t.references :user, null: false, foreign_key: true
-      t.integer :visibility
-
-      t.timestamps
-    end
-  end
-end

+ 0 - 36
db/migrate/20211209144738_create_active_storage_tables.active_storage.rb

@@ -1,36 +0,0 @@
-# This migration comes from active_storage (originally 20170806125915)
-class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
-  def change
-    create_table :active_storage_blobs do |t|
-      t.string   :key,          null: false
-      t.string   :filename,     null: false
-      t.string   :content_type
-      t.text     :metadata
-      t.string   :service_name, null: false
-      t.bigint   :byte_size,    null: false
-      t.string   :checksum,     null: false
-      t.datetime :created_at,   null: false
-
-      t.index [ :key ], unique: true
-    end
-
-    create_table :active_storage_attachments do |t|
-      t.string     :name,     null: false
-      t.references :record,   null: false, polymorphic: true, index: false
-      t.references :blob,     null: false
-
-      t.datetime :created_at, null: false
-
-      t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true
-      t.foreign_key :active_storage_blobs, column: :blob_id
-    end
-
-    create_table :active_storage_variant_records do |t|
-      t.belongs_to :blob, null: false, index: false
-      t.string :variation_digest, null: false
-
-      t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true
-      t.foreign_key :active_storage_blobs, column: :blob_id
-    end
-  end
-end

+ 0 - 20
db/migrate/20211209155645_create_users.rb

@@ -1,20 +0,0 @@
-class CreateUsers < ActiveRecord::Migration[6.1]
-  def change
-    create_table :users do |t|
-      t.string :username
-      t.string :full_name
-      t.string :first_name
-      t.string :last_name
-      t.string :tagline
-      t.string :bio
-      t.string :country
-      t.string :city
-      t.string :password
-      t.string :salt
-      t.boolean :admin
-      t.integer :visibility
-
-      t.timestamps
-    end
-  end
-end

+ 0 - 12
db/migrate/20211209161003_create_mail_adresses.rb

@@ -1,12 +0,0 @@
-class CreateMailAdresses < ActiveRecord::Migration[6.1]
-  def change
-    create_table :mail_adresses do |t|
-      t.references :user, null: false, foreign_key: true
-      t.string :address
-      t.integer :priority
-      t.integer :visibility
-
-      t.timestamps
-    end
-  end
-end

+ 0 - 12
db/migrate/20211209221626_create_texts.rb

@@ -1,12 +0,0 @@
-class CreateTexts < ActiveRecord::Migration[6.1]
-  def change
-    create_table :texts do |t|
-      t.references :user, null: false, foreign_key: true
-      t.string :key
-      t.string :language
-      t.text :text
-
-      t.timestamps
-    end
-  end
-end

+ 0 - 10
db/migrate/20211210121307_create_technologies.rb

@@ -1,10 +0,0 @@
-class CreateTechnologies < ActiveRecord::Migration[6.1]
-  def change
-    create_table :technologies do |t|
-      t.string :name
-      t.integer :nature
-
-      t.timestamps
-    end
-  end
-end

+ 0 - 8
db/migrate/20211210121633_create_users_technologies_join_table.rb

@@ -1,8 +0,0 @@
-class CreateUsersTechnologiesJoinTable < ActiveRecord::Migration[6.1]
-  def change
-    create_join_table :users, :technologies do |t|
-    t.index :user_id
-    t.index :technology_id
-    end
-  end
-end

+ 0 - 5
db/migrate/20211210122542_add_fieldname_to_technologies_users.rb

@@ -1,5 +0,0 @@
-class AddFieldnameToTechnologiesUsers < ActiveRecord::Migration[6.1]
-  def change
-    add_column :technologies_users, :value, :tinyint
-  end
-end

+ 0 - 8
db/migrate/20211210122634_create_projects_technologies_join_table.rb

@@ -1,8 +0,0 @@
-class CreateProjectsTechnologiesJoinTable < ActiveRecord::Migration[6.1]
-  def change
-    create_join_table :projects, :technologies do |t|
-    t.index :project_id
-    t.index :technology_id
-    end
-  end
-end

+ 0 - 5
db/migrate/20211210122749_add_fieldname_to_projects_technologies.rb

@@ -1,5 +0,0 @@
-class AddFieldnameToProjectsTechnologies < ActiveRecord::Migration[6.1]
-  def change
-    add_column :projects_technologies, :value, :tinyint
-  end
-end

+ 0 - 10
db/migrate/20211210124959_create_tags.rb

@@ -1,10 +0,0 @@
-class CreateTags < ActiveRecord::Migration[6.1]
-  def change
-    create_table :tags do |t|
-      t.references :project, null: false, foreign_key: true
-      t.string :tag
-
-      t.timestamps
-    end
-  end
-end

+ 0 - 10
db/migrate/20211211222327_create_url_targets.rb

@@ -1,10 +0,0 @@
-class CreateUrlTargets < ActiveRecord::Migration[6.1]
-  def change
-    create_table :url_targets do |t|
-      t.string :name
-      t.string :summary
-
-      t.timestamps
-    end
-  end
-end

+ 0 - 11
db/migrate/20211211231839_create_project_url.rb

@@ -1,11 +0,0 @@
-class CreateProjectUrl < ActiveRecord::Migration[6.1]
-  def change
-    create_table :project_urls do |t|
-      t.references :project, null: false, type: :bigint
-      t.string :url
-      t.references :urlTarget, null: false, type: :bigint
-
-      t.timestamps
-    end
-  end
-end

+ 0 - 10
db/migrate/20211212113709_create_licenses.rb

@@ -1,10 +0,0 @@
-class CreateLicenses < ActiveRecord::Migration[6.1]
-  def change
-    create_table :licenses do |t|
-      t.string :name
-      t.string :url
-
-      t.timestamps
-    end
-  end
-end

+ 0 - 12
db/migrate/20211213092427_create_social_links.rb

@@ -1,12 +0,0 @@
-class CreateSocialLinks < ActiveRecord::Migration[6.1]
-  def change
-    create_table :social_links do |t|
-      t.string :site_name
-      t.string :pattern
-      t.string :regexp
-      t.string :link_title
-
-      t.timestamps
-    end
-  end
-end

+ 0 - 12
db/migrate/20211213094550_create_user_social_links.rb

@@ -1,12 +0,0 @@
-class CreateUserSocialLinks < ActiveRecord::Migration[6.1]
-  def change
-    create_table :user_social_links do |t|
-      t.references :user, null: false, foreign_key: true
-      t.references :social_link, null: false, foreign_key: true
-      t.integer :priority
-      t.string :link
-
-      t.timestamps
-    end
-  end
-end

+ 0 - 13
db/migrate/20211213105552_create_resumes.rb

@@ -1,13 +0,0 @@
-class CreateResumes < ActiveRecord::Migration[6.1]
-  def change
-    create_table :resumes do |t|
-      t.references :user, null: false, foreign_key: true
-      t.string :language
-      t.integer :priority
-      t.boolean :printable
-      t.string :format
-
-      t.timestamps
-    end
-  end
-end

+ 0 - 15
db/migrate/20211228133200_create_messages.rb

@@ -1,15 +0,0 @@
-class CreateMessages < ActiveRecord::Migration[6.1]
-  def change
-    create_table :messages do |t|
-      t.references :user, null: false, foreign_key: true
-      t.string :sender_name
-      t.string :sender_email
-      t.text :text
-      t.datetime :dtime
-      t.string :language
-      t.string :ip
-
-      t.timestamps
-    end
-  end
-end

+ 12 - 10
db/schema.rb

@@ -10,7 +10,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.
 
-ActiveRecord::Schema.define(version: 2021_12_28_133200) do
+ActiveRecord::Schema.define(version: 2021_12_30_103227) do
 
   create_table "active_storage_attachments", charset: "utf8mb4", force: :cascade do |t|
     t.string "name", null: false
@@ -74,6 +74,7 @@ ActiveRecord::Schema.define(version: 2021_12_28_133200) do
     t.bigint "project_id", null: false
     t.string "url"
     t.bigint "urlTarget_id", null: false
+    t.boolean "deprecated"
     t.datetime "created_at", precision: 6, null: false
     t.datetime "updated_at", precision: 6, null: false
     t.index ["project_id"], name: "index_project_urls_on_project_id"
@@ -88,6 +89,7 @@ ActiveRecord::Schema.define(version: 2021_12_28_133200) do
     t.string "logo"
     t.string "header"
     t.text "text"
+    t.text "comment"
     t.bigint "license_id", null: false
     t.bigint "user_id", null: false
     t.integer "visibility"
@@ -125,13 +127,13 @@ ActiveRecord::Schema.define(version: 2021_12_28_133200) do
     t.datetime "updated_at", precision: 6, null: false
   end
 
-  create_table "tags", charset: "utf8mb4", force: :cascade do |t|
-    t.bigint "project_id", null: false
-    t.string "tag"
-    t.datetime "created_at", precision: 6, null: false
-    t.datetime "updated_at", precision: 6, null: false
-    t.index ["project_id"], name: "index_tags_on_project_id"
-  end
+  #create_table "tags", charset: "utf8mb4", force: :cascade do |t|
+  #  t.bigint "project_id", null: false
+  #  t.string "tag"
+  #  t.datetime "created_at", precision: 6, null: false
+  #  t.datetime "updated_at", precision: 6, null: false
+  #  t.index ["project_id"], name: "index_tags_on_project_id"
+  #end
 
   create_table "technologies", charset: "utf8mb4", force: :cascade do |t|
     t.string "name"
@@ -149,7 +151,7 @@ ActiveRecord::Schema.define(version: 2021_12_28_133200) do
   end
 
   create_table "texts", charset: "utf8mb4", force: :cascade do |t|
-    t.bigint "user_id", null: false
+    t.bigint "user_id", null: true
     t.string "key"
     t.string "language"
     t.text "text"
@@ -200,7 +202,7 @@ ActiveRecord::Schema.define(version: 2021_12_28_133200) do
   add_foreign_key "projects", "licenses"
   add_foreign_key "projects", "users"
   add_foreign_key "resumes", "users"
-  add_foreign_key "tags", "projects"
+  #add_foreign_key "tags", "projects"
   add_foreign_key "texts", "users"
   add_foreign_key "user_social_links", "social_links"
   add_foreign_key "user_social_links", "users"

+ 265 - 0
db/seeds.rb

@@ -5,3 +5,268 @@
 #
 #   movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
 #   Character.create(name: 'Luke', movie: movies.first)
+
+license = License.new(id: 1, name: "GPLv3", url: "https://www.gnu.org/licenses/gpl-3.0.en.html")
+license.save
+license.logo.attach(io: File.open("custom_data/attachments/license/1/logo/1.svg"), filename: 'GPLv3.svg')
+license.save
+
+#tag = Tag.new(project_id: 1, tag: "tag.js")
+#tag.save
+#tag = Tag.new(project_id: 1, tag: "tag.html5")
+#tag.save
+#tag = Tag.new(project_id: 2, tag: "tag.html5")
+#tag.save
+#tag = Tag.new(project_id: 2, tag: "tag.js")
+#tag.save
+#tag = Tag.new(project_id: 2, tag: "tag.css3")
+#tag.save
+#tag = Tag.new(project_id: 2, tag: "tag.android")
+#tag.save
+#tag = Tag.new(project_id: 2, tag: "tag.ios")
+#tag.save
+#tag = Tag.new(project_id: 2, tag: "tag.java")
+#tag.save
+#tag = Tag.new(project_id: 2, tag: "tag.swift")
+#tag.save
+#tag = Tag.new(project_id: 2, tag: "tag.php")
+#tag.save
+#tag = Tag.new(project_id: 3, tag: "tag.ruby")
+#tag.save
+#tag = Tag.new(project_id: 3, tag: "tag.rails")
+#tag.save
+#tag = Tag.new(project_id: 3, tag: "tag.mysql")
+#tag.save
+#tag = Tag.new(project_id: 3, tag: "tag.html5")
+#tag.save
+#tag = Tag.new(project_id: 3, tag: "tag.js")
+#tag.save
+#tag = Tag.new(project_id: 4, tag: "tag.html5")
+#tag.save
+#tag = Tag.new(project_id: 4, tag: "tag.css3")
+#tag.save
+#tag = Tag.new(project_id: 4, tag: "tag.js")
+#tag.save
+#tag = Tag.new(project_id: 4, tag: "tag.php")
+#tag.save
+#tag = Tag.new(project_id: 4, tag: "tag.sqlite")
+#tag.save
+
+technology = Technology.new(id: 1, name: "PHP", nature: "1")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/1/logo/1.png"), filename: 'php.png')
+technology.save
+technology = Technology.new(id: 2, name: "JavaScript", nature: "1")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/2/logo/1.png"), filename: 'javascript.png')
+technology.save
+technology = Technology.new(id: 3, name: "Java", nature: "1")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/3/logo/1.png"), filename: 'java.png')
+technology.save
+technology = Technology.new(id: 4, name: "Swift", nature: "1")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/4/logo/1.png"), filename: 'swift.png')
+technology.save
+technology = Technology.new(id: 5, name: "Ruby", nature: "1")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/5/logo/1.png"), filename: 'ruby.png')
+technology.save
+technology = Technology.new(id: 6, name: "Python", nature: "1")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/6/logo/1.png"), filename: 'python.png')
+technology.save
+technology = Technology.new(id: 7, name: "C", nature: "1")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/7/logo/1.png"), filename: 'c.png')
+technology.save
+technology = Technology.new(id: 8, name: "C++", nature: "1")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/8/logo/1.png"), filename: 'cpp.png')
+technology.save
+technology = Technology.new(id: 9, name: "Bash", nature: "1")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/9/logo/1.png"), filename: 'bash.png')
+technology.save
+technology = Technology.new(id: 10, name: "Powershell", nature: "1")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/10/logo/1.png"), filename: 'powershell.png')
+technology.save
+technology = Technology.new(id: 11, name: "Rails", nature: "2")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/11/logo/1.png"), filename: 'rails.png')
+technology.save
+technology = Technology.new(id: 12, name: "MySQL", nature: "3")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/12/logo/1.png"), filename: 'mysql.png')
+technology.save
+technology = Technology.new(id: 13, name: "SQLite", nature: "3")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/13/logo/1.png"), filename: 'sqlite.png')
+technology.save
+technology = Technology.new(id: 14, name: "Oracle Database", nature: "3")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/14/logo/1.png"), filename: 'oracledb.png')
+technology.save
+technology = Technology.new(id: 15, name: "HTML5", nature: "4")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/15/logo/1.png"), filename: 'html5.png')
+technology.save
+technology = Technology.new(id: 16, name: "CSS3", nature: "4")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/16/logo/1.png"), filename: 'css3.png')
+technology.save
+technology = Technology.new(id: 17, name: "GNU/Linux", nature: "5")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/17/logo/1.png"), filename: 'gnulinux.png')
+technology.save
+technology = Technology.new(id: 18, name: "MS Windows", nature: "5")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/18/logo/1.png"), filename: 'windows.png')
+technology.save
+technology = Technology.new(id: 19, name: "Android", nature: "5")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/19/logo/1.png"), filename: 'android.png')
+technology.save
+technology = Technology.new(id: 20, name: "iOS", nature: "5")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/20/logo/1.png"), filename: 'ios.png')
+technology.save
+technology = Technology.new(id: 21, name: "GIT", nature: "6")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/21/logo/1.png"), filename: 'git.png')
+technology.save
+technology = Technology.new(id: 22, name: "Apache", nature: "6")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/22/logo/1.png"), filename: 'apache.png')
+technology.save
+technology = Technology.new(id: 23, name: "Maven", nature: "6")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/23/logo/1.png"), filename: 'maven.png')
+technology.save
+technology = Technology.new(id: 24, name: "WebLogic", nature: "6")
+technology.save
+technology.logo.attach(io: File.open("custom_data/attachments/technology/24/logo/1.png"), filename: 'weblogic.png')
+technology.save
+
+target = UrlTarget.new(id: 1, name: "urltarget.1.name", summary: "urltarget.1.summary")
+target.save
+target.logo.attach(io: File.open("custom_data/attachments/urlTarget/1/logo/1.svg"), filename: 'website.svg')
+target.save
+target = UrlTarget.new(id: 2, name: "urltarget.2.name", summary: "urltarget.2.summary")
+target.save
+target.logo.attach(io: File.open("custom_data/attachments/urlTarget/2/logo/1.svg"), filename: 'github.svg')
+target.save
+target = UrlTarget.new(id: 3, name: "urltarget.3.name", summary: "urltarget.3.summary")
+target.save
+target.logo.attach(io: File.open("custom_data/attachments/urlTarget/3/logo/1.svg"), filename: 'googleplay.svg')
+target.save
+target = UrlTarget.new(id: 4, name: "urltarget.4.name", summary: "urltarget.4.summary")
+target.save
+target.logo.attach(io: File.open("custom_data/attachments/urlTarget/4/logo/1.svg"), filename: 'appstore.svg')
+target.save
+
+text = Text.new(user_id: nil, key: "urltarget.1.name", language: "es", text: "Sitio web")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.1.name", language: "en", text: "Website")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.1.name", language: "eu", text: "Web horria")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.1.summary", language: "es", text: "Ir al sitio web.")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.1.summary", language: "en", text: "Go to website.")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.1.summary", language: "eu", text: "Web horria.")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.2.name", language: "es", text: "Github")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.2.name", language: "en", text: "Github")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.2.name", language: "eu", text: "Github")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.2.summary", language: "es", text: "Ver el código fuente en Github.")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.2.summary", language: "en", text: "Checkout source code on Github.")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.2.summary", language: "eu", text: "Kodea Github-n.")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.3.name", language: "es", text: "Google Play")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.3.name", language: "en", text: "Google Play")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.3.name", language: "eu", text: "Google Play")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.3.summary", language: "es", text: "Ver app en Google Play.")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.3.summary", language: "en", text: "See on Google Play.")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.3.summary", language: "eu", text: "Google Play-n.")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.4.name", language: "es", text: "App Store")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.4.name", language: "en", text: "App Store")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.4.name", language: "eu", text: "App Store")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.4.summary", language: "es", text: "Ver app en App Store.")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.4.summary", language: "en", text: "See on Google Play.")
+text.save
+text = Text.new(user_id: nil, key: "urltarget.4.summary", language: "eu", text: "Google App Store-n.")
+text.save
+
+text = Text.new(user_id: nil, key: "sociallink.2.title", language: "es", text: "Ir a mi perfil en Github")
+text.save
+text = Text.new(user_id: nil, key: "sociallink.2.title", language: "en", text: "Check out my Github profile")
+text.save
+text = Text.new(user_id: nil, key: "sociallink.2.title", language: "eu", text: "Ir a mi perfil en Github")
+text.save
+text = Text.new(user_id: nil, key: "sociallink.3.title", language: "es", text: "Escríbeme por Telegram")
+text.save
+text = Text.new(user_id: nil, key: "sociallink.3.title", language: "en", text: "Drop me a line over Telegram")
+text.save
+text = Text.new(user_id: nil, key: "sociallink.3.title", language: "eu", text: "Escríbeme por Telegram")
+text.save
+text = Text.new(user_id: nil, key: "sociallink.4.title", language: "es", text: "Ver mi perfil en LinkedIn")
+text.save
+text = Text.new(user_id: nil, key: "sociallink.4.title", language: "en", text: "See my LinkedIn profile")
+text.save
+text = Text.new(user_id: nil, key: "sociallink.4.title", language: "eu", text: "Ver mi perfil en LinkedIn")
+text.save
+text = Text.new(user_id: nil, key: "sociallink.5.title", language: "es", text: "Ver mi perfil en Facebook")
+text.save
+text = Text.new(user_id: nil, key: "sociallink.5.title", language: "en", text: "See my Facebook profile")
+text.save
+text = Text.new(user_id: nil, key: "sociallink.5.title", language: "eu", text: "Ver mi perfil en Facebook")
+text.save
+text = Text.new(user_id: nil, key: "sociallink.6.title", language: "es", text: "Ver mi perfil en Twitter")
+text.save
+text = Text.new(user_id: nil, key: "sociallink.6.title", language: "en", text: "See my Twitter profile")
+text.save
+text = Text.new(user_id: nil, key: "sociallink.6.title", language: "eu", text: "Ver mi perfil en Twitter")
+text.save
+
+slink = SocialLink.new(id: 1, site_name: "eMail", pattern: "mailto:*", regexp: "^\S+@\S+\.\S+$", link_title: "sociallink.1.title")
+slink.save
+slink.logo.attach(io: File.open("custom_data/attachments/socialLink/1/logo/1.svg"), filename: 'email.svg')
+slink.save
+slink = SocialLink.new(id: 2, site_name: "Github", pattern: "https://github.com/*", regexp: "^.+$", link_title: "sociallink.2.title")
+slink.save
+slink.logo.attach(io: File.open("custom_data/attachments/socialLink/2/logo/1.svg"), filename: 'github.svg')
+slink.save
+slink = SocialLink.new(id: 3, site_name: "Telegram", pattern: "https://t.me/*", regexp: "^.+$", link_title: "sociallink.3.title")
+slink.save
+slink.logo.attach(io: File.open("custom_data/attachments/socialLink/3/logo/1.svg"), filename: 'telegram.svg')
+slink.save
+slink = SocialLink.new(id: 4, site_name: "LinkedIn", pattern: "https://www.linkedin.com/in/*", regexp: "^.+$", link_title: "sociallink.4.title")
+slink.save
+slink.logo.attach(io: File.open("custom_data/attachments/socialLink/4/logo/1.svg"), filename: 'linkedin.svg')
+slink.save
+slink = SocialLink.new(id: 5, site_name: "Facebook", pattern: "https://facebook.com/*", regexp: "^.+$", link_title: "sociallink.5.title")
+slink.save
+slink.logo.attach(io: File.open("custom_data/attachments/socialLink/5/logo/1.svg"), filename: 'facebook.svg')
+slink.save
+slink = SocialLink.new(id: 6, site_name: "Twitter", pattern: "https://twitter.com/*", regexp: "^.+$", link_title: "sociallink.6.title")
+slink.save
+slink.logo.attach(io: File.open("custom_data/attachments/socialLink/6/logo/1.svg"), filename: 'twitter.svg')
+slink.save

BIN
public/fonts/Handwritten.ttf


+ 7 - 0
test/controllers/error_controller_test.rb

@@ -0,0 +1,7 @@
+require "test_helper"
+
+class ErrorControllerTest < ActionDispatch::IntegrationTest
+  # test "the truth" do
+  #   assert true
+  # end
+end

Неке датотеке нису приказане због велике количине промена