Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
90c20f7
Codeclimate - Ignore lib files (#150)
Duxy1996 Sep 4, 2019
8f4546f
RestoredObject - View - Removed sort sentence (#151)
Duxy1996 Sep 4, 2019
ea0e40d
Codeclimate - Updated .codecliamte file with more ignored files (#152)
Duxy1996 Sep 4, 2019
97dbc7b
[Security] Bump nokogiri from 1.10.3 to 1.10.4 (#141)
dependabot-preview[bot] Sep 4, 2019
3da7f91
Travis - Updated Travis CI to Rails 2.4.0 (#153)
Duxy1996 Sep 4, 2019
82a68da
Bump devise from 4.6.2 to 4.7.1 (#155)
dependabot-preview[bot] Sep 9, 2019
09ebd30
Bump devise-i18n from 1.8.0 to 1.8.1 (#138)
dependabot-preview[bot] Sep 9, 2019
d5d4b92
Bump bcrypt from `011b67b` to `2875dbf` (#145)
dependabot-preview[bot] Sep 9, 2019
78fd7a9
INDEX - Nil check needed. If there is not a featured museum in the bd…
Duxy1996 Sep 18, 2019
74c712b
Feature/badges generator (#165)
Duxy1996 Oct 1, 2019
2884a31
WIP: Features/add tests (#166)
Duxy1996 Oct 2, 2019
58ae0d5
Feature/update readme (#169)
Duxy1996 Oct 7, 2019
893b346
CATEGORY - [FRAGMENTX-15] - Model validation for category model and t…
Duxy1996 Oct 7, 2019
7850457
GITIGNORE - Added json files type to ignore list
Duxy1996 Oct 7, 2019
4aca860
GEMFILE - Updated railszip gem
Duxy1996 Oct 7, 2019
9059251
CATEGORY - Fixed copy paste typo in category test fle
Duxy1996 Oct 8, 2019
2364a87
MATERIAL - Added name validation for material model
Duxy1996 Oct 8, 2019
0668e77
COLLECTION - Added valdiation tests for collection
Duxy1996 Oct 10, 2019
4987890
USER - Added several validation test for user model (DEVISE)
Duxy1996 Oct 10, 2019
842b12b
COLLECTION - Fixed travis test issue. Needed a user in db to pass the…
Duxy1996 Oct 10, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ exclude_patterns:
- "public/js/PLYLoader.js"
- "public/js/STLLoader.js"
- "public/js/three.min.js"
- "public/js/OBJLoader.js"
- "public/js/OBJLoader2.js"
- "public/js/LoaderSupport.js"
- "public/js/OutlinePass.js"
- "public/js/MTLLoader.js"
- "public/js/EffectComposer.js"
- "db"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@
.byebug_history

*.DS_Store

*.json
11 changes: 7 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
addons:
postgresql: 9.6

language: ruby
os: linux

Expand All @@ -11,9 +14,9 @@ before_install:
env:
- DB=postgresql

before_script:
- rails db:create
- rails db:migrate
script:
- rails db:drop db:create db:migrate RAILS_ENV=test
- rails test

rvm:
- 2.3.3
- 2.5.0
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ gem 'bootstrap'

gem 'geocoder'

gem 'rubyzip'
gem 'rubyzip', '>= 1.3.0'

gem 'bootstrap4-kaminari-views'
gem 'kaminari'
Expand Down
20 changes: 10 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/codahale/bcrypt-ruby.git
revision: 011b67ba550457dab5d6084128888f08476f278a
revision: 2875dbf4359ef9ce88775f4aae67aaa011f930fa
specs:
bcrypt (3.1.13)

Expand Down Expand Up @@ -99,13 +99,13 @@ GEM
coffee-script-source (1.12.2)
concurrent-ruby (1.1.5)
crass (1.0.4)
devise (4.6.2)
devise (4.7.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 6.0)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
devise-i18n (1.8.0)
devise-i18n (1.8.1)
devise (>= 4.6)
erubi (1.8.0)
execjs (2.7.0)
Expand Down Expand Up @@ -154,9 +154,9 @@ GEM
minitest (5.11.3)
multi_json (1.13.1)
nio4r (2.4.0)
nokogiri (1.10.3)
nokogiri (1.10.4)
mini_portile2 (~> 2.4.0)
nokogiri (1.10.3-x86-mingw32)
nokogiri (1.10.4-x86-mingw32)
mini_portile2 (~> 2.4.0)
orm_adapter (0.5.0)
pg (1.1.4)
Expand Down Expand Up @@ -187,7 +187,7 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
rails-html-sanitizer (1.2.0)
loofah (~> 2.2, >= 2.2.2)
railties (5.2.3)
actionpack (= 5.2.3)
Expand All @@ -205,7 +205,7 @@ GEM
responders (3.0.0)
actionpack (>= 5.0)
railties (>= 5.0)
rubyzip (1.2.3)
rubyzip (1.3.0)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
Expand Down Expand Up @@ -290,7 +290,7 @@ DEPENDENCIES
pundit
rack-cors
rails (~> 5.2.1)
rubyzip
rubyzip (>= 1.3.0)
sass-rails (~> 5.0)
selenium-webdriver
turbolinks (~> 5)
Expand All @@ -300,4 +300,4 @@ DEPENDENCIES
wicked

BUNDLED WITH
1.17.2
1.17.3
146 changes: 145 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,150 @@
# FragmentX

## 3D Visualization of restored objects

[![Build Status](https://travis-ci.org/FragmentX/FRAGMENTX.svg?branch=master)](https://travis-ci.org/FragmentX/FRAGMENTX) [![Maintainability](https://api.codeclimate.com/v1/badges/900fd8a114c8d71e0142/maintainability)](https://codeclimate.com/github/FragmentX/FRAGMENTX/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/900fd8a114c8d71e0142/test_coverage)](https://codeclimate.com/github/FragmentX/FRAGMENTX/test_coverage) [![security](https://hakiri.io/github/FragmentX/FRAGMENTX/master.svg)](https://hakiri.io/github/FragmentX/FRAGMENTX/master)

http://scanviewer.herokuapp.com/


[//]: # (badges)
[![security](https://img.shields.io/badge/contributors-4-blue)](https://img.shields.io/badge/contributors-4-blue)

[//]: # (badges)

> [FragmentX web](http://scanviewer.herokuapp.com/)
>
> [http://scanviewer.herokuapp.com/](http://scanviewer.herokuapp.com/)
>

## Description
FragmentX is an open source 3D objects viewer build using Ruby on Rails and Three JS. Is part of an European project in the UPV and the final degree project of one of the creators.

FragmentX tries to bring to museums in particular and people in general a tool to store and visualize masterpieces and any type of 3D objects. Often this kind of objects are fragmented or divided in several pieces. Our 3D viewer is able to show all the fragments of these objects.

The platform created is on the web because we wanted to create a more accessible tool for everybody. It could be used in any device.

## Version
The application is under development. This means that there is not a release or a beta version yet. The FragmentX team and its community is working on its first beta release.

### 0.2 Alpha 20181127
#### Features
* [X] OBJ file format loader
* [X] Orthographic and Perspective cameras switch
* [X] Added continuous Integration
* [X] Added code quality checker
* [X] Added vulnerability checker
* [X] Added dependaBot
#### Bugs
* [X] Orthographic fails when is switched a few times


#### Changes
* [X] Redesigned interface
* [X] Refactored Code


### 0.1 Alpha 20180713

#### Features
* [X] STL file format loader
* [X] ZIP automatic restored object loader
* [X] 3D Restored Object viewer
* [X] Clipping X, Y, Z planes
* [X] Canvas Screenshoot
* [X] Pieces measurement
* [X] Show nearby pieces
* [X] Basic design and lading page
* [X] Async pieces loader using ThreeJS web workers
* [X] Automatic deploy on Heroku
* [X] Translations (English and Spanish)


## Installation

### Dependecies
* Ruby version: [2.6](https://www.ruby-lang.org/es/news/2019/03/13/ruby-2-6-2-released/)
* Rails version: [5.2.3](https://weblog.rubyonrails.org/2019/3/28/Rails-5-2-3-has-been-released/)
* PostgreSQL version: [9.5](https://www.postgresql.org/docs/9.5/index.html)
* NodeJS version: [10.16.3](https://nodejs.org/uk/blog/release/v0.10.16/)
* gcc and g++ version: [5.4](https://ftp.gnu.org/gnu/gcc/gcc-5.4.0/)

### Recomended
* Ubuntu 16.04~18.04, Kubuntu, or Debian based OS
* Git
### Installation steps

* Update the Ubuntu repositories
```shell
sudo apt-get update
```
* Install basic dependencies for Ruby on Rails (Git is optional)
```shell
sudo apt-get install git
sudo apt install curl
sudo apt install -y nodejs
sudo apt install gcc g++ make
```
* Clone the repo from our master branch
```shell
git clone https://github.com/FragmentX/FRAGMENTX.git
cd FRAGMENTX/
```
* Ruby installation and basic setup of the rvm
```shell
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable --ruby
source /home/duxy1996/.rvm/scripts/rvm
rvm install ruby-2.6.1
rvm --default use ruby-2.6.1
```
* Rails 5.2.0 installation
```shell
gem update --system
gem install rails -v 5.2.0
```
* PostgreSQL database installation and postgresql gem installation
```shell
sudo apt install postgresql postgresql-contrib libpq-dev -y
systemctl start postgresql
systemctl enable postgresql
```
* Ruby basic gem installation
```shell
sudo apt-get install ruby-railties
sudo apt install ruby-bundler
bundle install
```
* Database creation and migration. Applies all the changes made in the migrations folder. It is empty, to feed the database should run ` rails db:seed`. With the `rails s` command the appplication is launched in localhost:3000
```shell
rails db:create
rails db:migrate
rails s
```
#### Optional
PostgreSQL sometimes is not well set up. You have to modify the file **pg_hba.conf** to allow to enter to the database and create the profile/user for manage the application databases.
```shell
sudo gedit /etc/postgresql/9.5/main/pg_hba.conf
```

## Contributors


[Álvaro Casado Coscollá.](https://github.com/alvarocasadoc) Architect and developer

[ Carlos Durán Roca.](https://github.com/Duxy1996) Architect and developer

[Dependa Baller bot.](https://github.com/marketplace/dependabot-preview)

[//]: # (contributors)




## References


* [Ruby tests for models and controllers](https://guides.rubyonrails.org/testing.html)
* [PostgreSQL test database initialization error](https://stackoverflow.com/questions/19097558/pg-undefinedtable-error-relation-users-does-not-exist)
* [PostgreSQL test fixture error](https://stackoverflow.com/questions/58190137/database-error-on-executing-test-ruby-on-rails-with-postgres)
* [PostgreSQL Travis configuration](https://medium.com/hexient-labs/configuring-travis-ci-for-a-rails-project-d25bc2f2ba7e)

11 changes: 0 additions & 11 deletions app/controllers/restored_objects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,13 @@ def create
authorize @object
if params[:zip_file]
params[:pieces_attributes] = nil
puts "About to read the file"
Zip::File.open(params[:zip_file].path) do |zipfile|
puts "Reading zip file"
zipfile.glob('*{ply,stl,obj}') do |file|
puts "Reading #{file.name}"
# tempfile = Tempfile.new(File.basename(file.name))
# tempfile.binmode
# tempfile.write file.get_input_stream.read

puts "Reading matrix"
matrix = zipfile.glob("#{file.name.split('.').first}.txt").first.get_input_stream.read
puts matrix

piece = @object.pieces.create(name: file.name, matrix: matrix)
end
end
end

respond_to do |format|
if @object.save
format.html { redirect_to @object }
Expand Down
2 changes: 2 additions & 0 deletions app/models/category.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Category < ApplicationRecord
has_many :categories_restored_objects
has_many :restored_objects, through: :categories_restored_objects

validates :name, presence: true
end
4 changes: 4 additions & 0 deletions app/models/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ def featured_image
'/object.svg'
end
end

validates :title, presence: true
validates :title, length: { minimum: 2 }
validates :description, length: { maximum: 500 }
end
2 changes: 2 additions & 0 deletions app/models/material.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Material < ApplicationRecord
has_many :compositions
has_many :restored_objects, through: :compositions

validates :name, presence: true
end
2 changes: 0 additions & 2 deletions app/models/object_format.rb

This file was deleted.

10 changes: 9 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class User < ApplicationRecord
has_many :collections

has_one_attached :avatar

has_one_attached :header

def header_image
Expand All @@ -24,4 +24,12 @@ def avatar_image
'/user.svg'
end
end

validates :name, presence: true
validates :name, length: { minimum: 2 }
validates :bio, length: { maximum: 500 }
validates :password, presence: true
validates :password, length: { in: 6..20 }
validates :email, presence: true

end
10 changes: 6 additions & 4 deletions app/views/home/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@
</div>
</section>

<% if @featured_museum != nil %>
<%= link_to @featured_museum, class: "no-decoration" do %>
<section id="featured" >
<div class="container">
<h2 class="fancy-title"><%= t('home.featured_museum') %></h2>
<p><%= t('home.featured_museum_info') %></p>
<br/>
<div class="user-header">
<h2 style="display: inline">
<%= image_tag @featured_museum.avatar_image, class: 'avatar' %>
<%= @featured_museum.name %>
<h2 style="display: inline">
<%= image_tag @featured_museum.avatar_image, class: 'avatar' %>
<%= @featured_museum.name %>
</h2>
</div>
<br/>
Expand Down Expand Up @@ -59,6 +60,7 @@
</div>
</div>
</section>
<% end %>

<section id="features">
<div class="container row" style="margin: 0 auto">
Expand Down Expand Up @@ -132,4 +134,4 @@ function render() {
document.addEventListener("turbolinks:load", function() {
render();
});
</script>
</script>
2 changes: 1 addition & 1 deletion app/views/restored_objects/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

<div class="container">
<div class="card-columns">
<% @objects.sort[3..-1].each_with_index do |obj, index| %>
<% @objects.each_with_index do |obj, index| %>
<div class="card">
<%= link_to image_tag(obj.featured_image, class:'card-img-top'), obj %>
<div class="card-body">
Expand Down
Loading