├── .gitattributes ├── .github └── workflows │ └── ruby.yml ├── .gitignore ├── Dockerfile ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── README.md ├── Rakefile ├── app ├── assets │ ├── config │ │ └── manifest.js │ ├── images │ │ └── .keep │ ├── javascripts │ │ ├── application.js │ │ ├── authentication.coffee │ │ ├── documents.coffee │ │ ├── folders.coffee │ │ ├── people.coffee │ │ ├── search.js │ │ ├── states.coffee │ │ ├── tags.coffee │ │ ├── users.coffee │ │ └── welcome.coffee │ └── stylesheets │ │ ├── application.css │ │ ├── authentication.scss │ │ ├── documents.scss │ │ ├── folders.scss │ │ ├── people.scss │ │ ├── search.scss │ │ ├── states.scss │ │ ├── tags.scss │ │ ├── users.scss │ │ └── welcome.scss ├── auth │ ├── authenticate_user.rb │ └── authorize_api_request.rb ├── controllers │ ├── application_controller.rb │ ├── authentication_controller.rb │ ├── concerns │ │ ├── .keep │ │ ├── exception_handler.rb │ │ └── response.rb │ ├── documents_controller.rb │ ├── folders_controller.rb │ ├── people_controller.rb │ ├── search_controller.rb │ ├── states_controller.rb │ ├── tags_controller.rb │ ├── users_controller.rb │ ├── version_controller.rb │ └── welcome_controller.rb ├── helpers │ ├── application_helper.rb │ ├── authentication_helper.rb │ ├── documents_helper.rb │ ├── folders_helper.rb │ ├── people_helper.rb │ ├── search_helper.rb │ ├── states_helper.rb │ ├── tags_helper.rb │ ├── users_helper.rb │ └── welcome_helper.rb ├── lib │ ├── json_web_token.rb │ └── message.rb ├── mailers │ └── .keep ├── models │ ├── .keep │ ├── concerns │ │ └── .keep │ ├── document.rb │ ├── documenttag.rb │ ├── folder.rb │ ├── person.rb │ ├── state.rb │ ├── tag.rb │ └── user.rb └── views │ └── layouts │ └── application.html.erb ├── bin ├── bundle ├── entrypoint.sh ├── rails ├── rake ├── setup └── spring ├── config.ru ├── config ├── application.rb ├── boot.rb ├── database.yml ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── assets.rb │ ├── backtrace_silencers.rb │ ├── cookies_serializer.rb │ ├── cors.rb │ ├── filter_parameter_logging.rb │ ├── inflections.rb │ ├── mime_types.rb │ ├── session_store.rb │ └── wrap_parameters.rb ├── locales │ └── en.yml ├── routes.rb ├── secrets.yml ├── settings.yml └── storage.yml ├── db ├── migrate │ ├── 20190525164329_create_states.rb │ ├── 20190525164336_create_users.rb │ ├── 20190525164530_create_folders.rb │ ├── 20190528071549_create_tags.rb │ ├── 20190528071703_create_people.rb │ ├── 20190528071704_create_documents.rb │ ├── 20190528071907_create_documenttags.rb │ ├── 20230731162630_change_index_on_folders.rb │ ├── 20230731163018_change_index_on_states.rb │ ├── 20240325214102_change_index_on_folders_again.rb │ ├── 20240331170409_add_secret_key_to_users.rb │ └── 20240331170416_add_encrypted_flag_to_documents.rb ├── schema.rb └── seeds.rb ├── docker-compose.yaml ├── everydocs-web-config.js ├── images ├── dashboard.png └── new-document.png ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── log └── .keep ├── public ├── 404.html ├── 422.html ├── 500.html ├── favicon.ico └── robots.txt ├── start-app.sh ├── stop-app.sh ├── test ├── controllers │ ├── .keep │ ├── authentication_controller_test.rb │ ├── documents_controller_test.rb │ ├── folders_controller_test.rb │ ├── people_controller_test.rb │ ├── search_controller_test.rb │ ├── states_controller_test.rb │ ├── tags_controller_test.rb │ ├── users_controller_test.rb │ └── welcome_controller_test.rb ├── fixtures │ ├── .keep │ ├── documents.yml │ ├── documenttags.yml │ ├── folders.yml │ ├── people.yml │ ├── states.yml │ ├── tags.yml │ └── users.yml ├── helpers │ └── .keep ├── integration │ └── .keep ├── mailers │ └── .keep ├── models │ ├── .keep │ ├── document_test.rb │ ├── documenttag_test.rb │ ├── folder_test.rb │ ├── person_test.rb │ ├── state_test.rb │ ├── tag_test.rb │ └── user_test.rb └── test_helper.rb └── vendor └── assets ├── javascripts └── .keep └── stylesheets └── .keep /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, 2 | # in case people don't have core.autocrlf set. 3 | * text=auto 4 | 5 | # Declares that files will always have CRLF line ends 6 | *.sh text eol=lf -------------------------------------------------------------------------------- /.github/workflows/ruby.yml: -------------------------------------------------------------------------------- 1 | name: Ruby 2 | on: [push, pull_request] 3 | permissions: 4 | contents: read 5 | jobs: 6 | test: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v4.1.0 10 | - name: Set up Ruby 11 | uses: ruby/setup-ruby@v1 12 | with: 13 | ruby-version: 3.4 14 | bundler-cache: true 15 | - name: Install dependencies 16 | run: | 17 | gem install rails 18 | bundle install 19 | - name: Check Ruby Syntax in .rb files 20 | run: find ./app/ | grep ".*\.rb$" | xargs -L 1 ruby -c 21 | - name: Setup database 22 | run: rails db:migrate RAILS_ENV=test 23 | - name: Run tests 24 | run: bundle exec rake 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore the default SQLite database. 11 | /db/*.sqlite3 12 | /db/*.sqlite3-journal 13 | 14 | # Ignore all logfiles and tempfiles. 15 | /log/* 16 | !/log/.keep 17 | /tmp 18 | 19 | # Ignore master key for decrypting credentials and more. 20 | /config/master.key 21 | /config/credentials.yml.enc 22 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ruby:3.4.2 2 | 3 | LABEL org.opencontainers.image.authors="Jonas Hellmann " 4 | 5 | RUN mkdir -p /var/everydocs-files 6 | WORKDIR /usr/src/app 7 | ENV RAILS_ENV=production 8 | ENV EVERYDOCS_DB_ADAPTER=mysql2 9 | ENV EVERYDOCS_DB_NAME=everydocs 10 | ENV EVERYDOCS_DB_USER=everydocs 11 | ENV EVERYDOCS_DB_HOST=localhost 12 | ENV EVERYDOCS_DB_PORT=3306 13 | 14 | COPY . . 15 | RUN rm -f Gemfile.lock 16 | RUN rm -rf .git/ 17 | RUN bundle install 18 | 19 | RUN apt-get update 20 | RUN apt-get install nodejs -y --no-install-recommends 21 | 22 | RUN EDITOR="mate --wait" bin/rails credentials:edit 23 | 24 | ENTRYPOINT ["./bin/entrypoint.sh"] 25 | CMD ["rails", "server", "-b", "0.0.0.0", "--port", "5678"] 26 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 4 | gem 'rails', '~> 8.0.1' 5 | # Use sqlite3 as the database for Active Record 6 | gem 'sqlite3', '>= 2.1' 7 | gem 'mysql2', '~> 0.5' 8 | # Use SCSS for stylesheets 9 | gem 'sassc-rails' 10 | # Use Uglifier as compressor for JavaScript assets 11 | gem 'uglifier', '>= 1.3.0' 12 | # See https://github.com/rails/execjs#readme for more supported runtimes 13 | # gem 'therubyracer', platforms: :ruby 14 | 15 | # Use jquery as the JavaScript library 16 | gem 'jquery-rails' 17 | # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks 18 | gem 'turbolinks' 19 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 20 | gem 'jbuilder', '~> 2.0' 21 | # bundle exec rake doc:rails generates the API under doc/api. 22 | gem 'sdoc', '~> 1.1.0', group: :doc 23 | 24 | # Use ActiveModel has_secure_password 25 | gem 'bcrypt', '~> 3.1.7' 26 | gem 'jwt' 27 | gem 'config' 28 | 29 | # Use OCR tool to extract text from pdf 30 | gem 'pdf-reader' 31 | 32 | # Rails server 33 | gem 'webrick', '>=1.8.2' 34 | 35 | gem 'rack-cors' 36 | gem 'lockbox', '=1.3.3' 37 | 38 | group :development, :test do 39 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console 40 | gem 'byebug' 41 | end 42 | 43 | group :development do 44 | # Access an IRB console on exception pages or by using <%= console %> in views 45 | gem 'web-console', '~> 2.0' 46 | 47 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 48 | gem 'spring' 49 | end 50 | 51 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | Ascii85 (2.0.1) 5 | actioncable (8.0.2) 6 | actionpack (= 8.0.2) 7 | activesupport (= 8.0.2) 8 | nio4r (~> 2.0) 9 | websocket-driver (>= 0.6.1) 10 | zeitwerk (~> 2.6) 11 | actionmailbox (8.0.2) 12 | actionpack (= 8.0.2) 13 | activejob (= 8.0.2) 14 | activerecord (= 8.0.2) 15 | activestorage (= 8.0.2) 16 | activesupport (= 8.0.2) 17 | mail (>= 2.8.0) 18 | actionmailer (8.0.2) 19 | actionpack (= 8.0.2) 20 | actionview (= 8.0.2) 21 | activejob (= 8.0.2) 22 | activesupport (= 8.0.2) 23 | mail (>= 2.8.0) 24 | rails-dom-testing (~> 2.2) 25 | actionpack (8.0.2) 26 | actionview (= 8.0.2) 27 | activesupport (= 8.0.2) 28 | nokogiri (>= 1.8.5) 29 | rack (>= 2.2.4) 30 | rack-session (>= 1.0.1) 31 | rack-test (>= 0.6.3) 32 | rails-dom-testing (~> 2.2) 33 | rails-html-sanitizer (~> 1.6) 34 | useragent (~> 0.16) 35 | actiontext (8.0.2) 36 | actionpack (= 8.0.2) 37 | activerecord (= 8.0.2) 38 | activestorage (= 8.0.2) 39 | activesupport (= 8.0.2) 40 | globalid (>= 0.6.0) 41 | nokogiri (>= 1.8.5) 42 | actionview (8.0.2) 43 | activesupport (= 8.0.2) 44 | builder (~> 3.1) 45 | erubi (~> 1.11) 46 | rails-dom-testing (~> 2.2) 47 | rails-html-sanitizer (~> 1.6) 48 | activejob (8.0.2) 49 | activesupport (= 8.0.2) 50 | globalid (>= 0.3.6) 51 | activemodel (8.0.2) 52 | activesupport (= 8.0.2) 53 | activerecord (8.0.2) 54 | activemodel (= 8.0.2) 55 | activesupport (= 8.0.2) 56 | timeout (>= 0.4.0) 57 | activestorage (8.0.2) 58 | actionpack (= 8.0.2) 59 | activejob (= 8.0.2) 60 | activerecord (= 8.0.2) 61 | activesupport (= 8.0.2) 62 | marcel (~> 1.0) 63 | activesupport (8.0.2) 64 | base64 65 | benchmark (>= 0.3) 66 | bigdecimal 67 | concurrent-ruby (~> 1.0, >= 1.3.1) 68 | connection_pool (>= 2.2.5) 69 | drb 70 | i18n (>= 1.6, < 2) 71 | logger (>= 1.4.2) 72 | minitest (>= 5.1) 73 | securerandom (>= 0.3) 74 | tzinfo (~> 2.0, >= 2.0.5) 75 | uri (>= 0.13.1) 76 | afm (0.2.2) 77 | base64 (0.3.0) 78 | bcrypt (3.1.20) 79 | benchmark (0.4.1) 80 | bigdecimal (3.2.2) 81 | binding_of_caller (1.0.1) 82 | debug_inspector (>= 1.2.0) 83 | builder (3.3.0) 84 | byebug (12.0.0) 85 | concurrent-ruby (1.3.5) 86 | config (5.5.2) 87 | deep_merge (~> 1.2, >= 1.2.1) 88 | ostruct 89 | connection_pool (2.5.3) 90 | crass (1.0.6) 91 | date (3.4.1) 92 | debug_inspector (1.2.0) 93 | deep_merge (1.2.2) 94 | drb (2.2.3) 95 | erb (5.0.1) 96 | erubi (1.13.1) 97 | execjs (2.10.0) 98 | ffi (1.17.2-aarch64-linux-gnu) 99 | ffi (1.17.2-aarch64-linux-musl) 100 | ffi (1.17.2-arm-linux-gnu) 101 | ffi (1.17.2-arm-linux-musl) 102 | ffi (1.17.2-arm64-darwin) 103 | ffi (1.17.2-x86_64-darwin) 104 | ffi (1.17.2-x86_64-linux-gnu) 105 | ffi (1.17.2-x86_64-linux-musl) 106 | globalid (1.2.1) 107 | activesupport (>= 6.1) 108 | hashery (2.1.2) 109 | i18n (1.14.7) 110 | concurrent-ruby (~> 1.0) 111 | io-console (0.8.0) 112 | irb (1.15.2) 113 | pp (>= 0.6.0) 114 | rdoc (>= 4.0.0) 115 | reline (>= 0.4.2) 116 | jbuilder (2.13.0) 117 | actionview (>= 5.0.0) 118 | activesupport (>= 5.0.0) 119 | jquery-rails (4.6.0) 120 | rails-dom-testing (>= 1, < 3) 121 | railties (>= 4.2.0) 122 | thor (>= 0.14, < 2.0) 123 | jwt (2.10.1) 124 | base64 125 | lockbox (1.3.3) 126 | logger (1.7.0) 127 | loofah (2.24.1) 128 | crass (~> 1.0.2) 129 | nokogiri (>= 1.12.0) 130 | mail (2.8.1) 131 | mini_mime (>= 0.1.1) 132 | net-imap 133 | net-pop 134 | net-smtp 135 | marcel (1.0.4) 136 | mini_mime (1.1.5) 137 | minitest (5.25.5) 138 | mysql2 (0.5.6) 139 | net-imap (0.5.8) 140 | date 141 | net-protocol 142 | net-pop (0.1.2) 143 | net-protocol 144 | net-protocol (0.2.2) 145 | timeout 146 | net-smtp (0.5.1) 147 | net-protocol 148 | nio4r (2.7.4) 149 | nokogiri (1.18.8-aarch64-linux-gnu) 150 | racc (~> 1.4) 151 | nokogiri (1.18.8-aarch64-linux-musl) 152 | racc (~> 1.4) 153 | nokogiri (1.18.8-arm-linux-gnu) 154 | racc (~> 1.4) 155 | nokogiri (1.18.8-arm-linux-musl) 156 | racc (~> 1.4) 157 | nokogiri (1.18.8-arm64-darwin) 158 | racc (~> 1.4) 159 | nokogiri (1.18.8-x86_64-darwin) 160 | racc (~> 1.4) 161 | nokogiri (1.18.8-x86_64-linux-gnu) 162 | racc (~> 1.4) 163 | nokogiri (1.18.8-x86_64-linux-musl) 164 | racc (~> 1.4) 165 | ostruct (0.6.1) 166 | pdf-reader (2.14.1) 167 | Ascii85 (>= 1.0, < 3.0, != 2.0.0) 168 | afm (~> 0.2.1) 169 | hashery (~> 2.0) 170 | ruby-rc4 171 | ttfunk 172 | pp (0.6.2) 173 | prettyprint 174 | prettyprint (0.2.0) 175 | psych (5.2.6) 176 | date 177 | stringio 178 | racc (1.8.1) 179 | rack (3.1.16) 180 | rack-cors (3.0.0) 181 | logger 182 | rack (>= 3.0.14) 183 | rack-session (2.1.1) 184 | base64 (>= 0.1.0) 185 | rack (>= 3.0.0) 186 | rack-test (2.2.0) 187 | rack (>= 1.3) 188 | rackup (2.2.1) 189 | rack (>= 3) 190 | rails (8.0.2) 191 | actioncable (= 8.0.2) 192 | actionmailbox (= 8.0.2) 193 | actionmailer (= 8.0.2) 194 | actionpack (= 8.0.2) 195 | actiontext (= 8.0.2) 196 | actionview (= 8.0.2) 197 | activejob (= 8.0.2) 198 | activemodel (= 8.0.2) 199 | activerecord (= 8.0.2) 200 | activestorage (= 8.0.2) 201 | activesupport (= 8.0.2) 202 | bundler (>= 1.15.0) 203 | railties (= 8.0.2) 204 | rails-dom-testing (2.3.0) 205 | activesupport (>= 5.0.0) 206 | minitest 207 | nokogiri (>= 1.6) 208 | rails-html-sanitizer (1.6.2) 209 | loofah (~> 2.21) 210 | nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) 211 | railties (8.0.2) 212 | actionpack (= 8.0.2) 213 | activesupport (= 8.0.2) 214 | irb (~> 1.13) 215 | rackup (>= 1.0.0) 216 | rake (>= 12.2) 217 | thor (~> 1.0, >= 1.2.2) 218 | zeitwerk (~> 2.6) 219 | rake (13.3.0) 220 | rdoc (6.14.0) 221 | erb 222 | psych (>= 4.0.0) 223 | reline (0.6.1) 224 | io-console (~> 0.5) 225 | ruby-rc4 (0.1.5) 226 | sassc (2.4.0) 227 | ffi (~> 1.9) 228 | sassc-rails (2.1.2) 229 | railties (>= 4.0.0) 230 | sassc (>= 2.0) 231 | sprockets (> 3.0) 232 | sprockets-rails 233 | tilt 234 | sdoc (1.1.0) 235 | rdoc (>= 5.0) 236 | securerandom (0.4.1) 237 | spring (4.3.0) 238 | sprockets (4.2.2) 239 | concurrent-ruby (~> 1.0) 240 | logger 241 | rack (>= 2.2.4, < 4) 242 | sprockets-rails (3.5.2) 243 | actionpack (>= 6.1) 244 | activesupport (>= 6.1) 245 | sprockets (>= 3.0.0) 246 | sqlite3 (2.6.0-aarch64-linux-gnu) 247 | sqlite3 (2.6.0-aarch64-linux-musl) 248 | sqlite3 (2.6.0-arm-linux-gnu) 249 | sqlite3 (2.6.0-arm-linux-musl) 250 | sqlite3 (2.6.0-arm64-darwin) 251 | sqlite3 (2.6.0-x86_64-darwin) 252 | sqlite3 (2.6.0-x86_64-linux-gnu) 253 | sqlite3 (2.6.0-x86_64-linux-musl) 254 | stringio (3.1.7) 255 | thor (1.3.2) 256 | tilt (2.6.0) 257 | timeout (0.4.3) 258 | ttfunk (1.8.0) 259 | bigdecimal (~> 3.1) 260 | turbolinks (5.2.1) 261 | turbolinks-source (~> 5.2) 262 | turbolinks-source (5.2.0) 263 | tzinfo (2.0.6) 264 | concurrent-ruby (~> 1.0) 265 | uglifier (4.2.1) 266 | execjs (>= 0.3.0, < 3) 267 | uri (1.0.3) 268 | useragent (0.16.11) 269 | web-console (2.3.0) 270 | activemodel (>= 4.0) 271 | binding_of_caller (>= 0.7.2) 272 | railties (>= 4.0) 273 | sprockets-rails (>= 2.0, < 4.0) 274 | webrick (1.9.1) 275 | websocket-driver (0.8.0) 276 | base64 277 | websocket-extensions (>= 0.1.0) 278 | websocket-extensions (0.1.5) 279 | zeitwerk (2.7.3) 280 | 281 | PLATFORMS 282 | aarch64-linux-gnu 283 | aarch64-linux-musl 284 | arm-linux-gnu 285 | arm-linux-musl 286 | arm64-darwin 287 | x86_64-darwin 288 | x86_64-linux-gnu 289 | x86_64-linux-musl 290 | 291 | DEPENDENCIES 292 | bcrypt (~> 3.1.7) 293 | byebug 294 | config 295 | jbuilder (~> 2.0) 296 | jquery-rails 297 | jwt 298 | lockbox (= 1.3.3) 299 | mysql2 (~> 0.5) 300 | pdf-reader 301 | rack-cors 302 | rails (~> 8.0.1) 303 | sassc-rails 304 | sdoc (~> 1.1.0) 305 | spring 306 | sqlite3 (>= 2.1) 307 | turbolinks 308 | uglifier (>= 1.3.0) 309 | web-console (~> 2.0) 310 | webrick (>= 1.8.2) 311 | 312 | BUNDLED WITH 313 | 2.6.2 314 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EveryDocs Core 2 | 3 | [![Build Status](https://img.shields.io/github/actions/workflow/status/jonashellmann/everydocs-core/ruby.yml??branch=main&style=flat-square)](https://github.com/jonashellmann/everydocs-core/actions?query=workflow%3ARuby) 4 | ![Lines of Code](https://img.shields.io/tokei/lines/github/jonashellmann/everydocs-core?style=flat-square) 5 | ![License](https://img.shields.io/github/license/jonashellmann/everydocs-core?style=flat-square) 6 | ![GitHub Repo 7 | Stars](https://img.shields.io/github/stars/jonashellmann/everydocs-core?style=social) 8 | [![Commit activity](https://img.shields.io/github/commit-activity/y/jonashellmann/everydocs-core?style=flat-square)](https://github.com/jonashellmann/everydocs-core/commits/) 9 | [![Last commit](https://img.shields.io/github/last-commit/jonashellmann/everydocs-core?style=flat-square)](https://github.com/jonashellmann/everydocs-core/commits/) 10 | 11 | EveryDocs Core is the server-side part of EveryDocs. This project contains a [web interface](https://github.com/jonashellmann/everydocs-web/). All in all, EveryDocs is a simple Document Management System (DMS) for private use. It contains basic functionality to organize your documents digitally. 12 | 13 | ## Features 14 | 15 | - Uploading PDF documents with a title, description and the date the document was created 16 | - Organizing documents in folders and subfolders 17 | - Adding people and processing states to documents 18 | - Extracting the content from the PDF file for full-text search 19 | - Encrypted storage of PDF files on disk 20 | - Encryption is automatically activated for all newly created users after upgrading to EveryDocs 1.5.0 21 | - For all other users encryption can be activated by adding a `secret_key` (generated for example by `openssl rand -hex 32`) and changing the flag `encryption_actived_flag` in the `users` database table for each user 22 | - If encrpytion is actived for a user, then there will be no content extraction and therefore no full-text search for this document 23 | - Searching all documents by title, description or content of the document 24 | - Creating new accounts (be aware that at the current moment everybody who knows the URL can create new accounts) 25 | - Authentication via JsonWebToken 26 | - REST-API for all CRUD operation for documents, folders, persons and processing states 27 | - Mobile-friendly web UI 28 | 29 | ## Screenshots of the web interface 30 | 31 | ![EveryDocs Web - Dashboard](images/dashboard.png) 32 | ![EveryDocs Web - Uploading new document](images/new-document.png) 33 | 34 | ## Installation 35 | 36 | ### Docker Compose (recommended) 37 | 38 | The easiest way to get started is to use Docker Compose. The ``docker-compose.yaml`` creates three containers for the database, Everydocs Core (available on port 5678) and the web interface (available on port 8080 and 8443). 39 | 40 | You may simply need to changed the URL in ``./everydocs-web-config.js`` where EveryDocs Core will be accessible and execute the following command while being inside the source folder of this repository: 41 |
SECRET_KEY_BASE="$(openssl rand -hex 64)" docker-compose up --build
42 | 43 | ### Docker (recommended) 44 | 45 | Start the container and make the API accessible on port ``8080`` by running the following commands. Of course, you can change the port in the last command. 46 | Also make sure to check the folder that is mounted into the container. In this case, the uploaded files are stored in ``/data/everydocs`` on the host. 47 |
docker run -p 127.0.0.1:8080:5678/tcp -e SECRET_KEY_BASE="$(openssl rand -hex 64)" -v /data/everydocs:/var/everydocs-files jonashellmann/everydocs
48 | 49 | You can configure the application by using the following environment variables: 50 | - ``EVERYDOCS_DB_ADAPTER``: The database adapter (default: ``mysql2``) 51 | - ``EVERYDOCS_DB_NAME``: The name of the database (default: ``everydocs``) 52 | - ``EVERYDOCS_DB_USER``: The user for the database connection (default: ``everydocs``) 53 | - ``EVERYDOCS_DB_PASSWORD``: The password for the database connection (no default) 54 | - ``EVERYDOCS_DB_HOST``: The host of the database (default: ``localhost``) 55 | - ``EVERYDOCS_DB_PORT``: The port of the database (default: ``3306``) 56 | 57 | You might want to include this container in a network so it has access to a database container. 58 | Also there are ways to connect to a database that runs on the host (e.g. see [Stackoverflow](https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach)). 59 | 60 | ### Manual Installation (not recommended) 61 | 62 | 1. Make sure you have Ruby installed. For an installation guide, check here: [Ruby installation guide](https://guides.rubyonrails.org/getting_started.html#installing-rails) 63 | 2. If you haven't installed the Rails Gem, you can run the following command: ``gem install rails`` 64 | 3. Download the newest release and unzip it in a location of your own choice. 65 | 4. Configure your database connection by setting the following environment variables: ``EVERYDOCS_DB_ADAPTER`` (e.g. mysql2), ``EVERYDOCS_DB_NAME``, ``EVERYDOCS_DB_USER``, ``EVERYDOCS_DB_PASSWORD``, ``EVERYDOCS_DB_HOST``, ``EVERYDOCS_DB_PORT``. 66 | You can do so by editing the ``start-app.sh`` script. 67 | 5. Configure the folder where documents are stored in config/settings.yml. 68 | The default location is ``/var/everydocs-files/``. 69 | 6. Install required dependencies by running: ``bundle install`` 70 | 7. You might want to change the port of the application in ``start-app.sh`` and ``stop-app.sh``. 71 | 8. Setup your database by running: ``rake db:migrate RAILS_ENV=production``. If there is an error, you might need to execute the following command, to 72 | set an encryption key: ``EDITOR="mate --wait" bin/rails credentials:edit`` 73 | 9. Make sure that the environment variable ``SECRET_KEY_BASE`` has a value. 74 | If not, you can generate a key by running ``rake secret`` and set it by editing the ``start-app.sh`` script. 75 | In case your not using production as your environment, the environment variable ``SECRET_KEY_BASE_DEV`` or ``SECRET_KEY_BASE_TEST`` needs to be set. 76 | 10. Start your Rails server: ``./start-app.sh`` 77 | 11. Access the application on http://localhost:5678 or configure any kind of proxy forwarding in your webserver. 78 | 12. If you wish to use this application in your web browser, consider to install [EveryDocs Web](https://github.com/jonashellmann/everydocs-web/)! 79 | 13. Stop the application: ``./stop-app.sh`` 80 | 81 | ## Backup 82 | 83 | To backup your application, you can simply use the backup functionality of your 84 | database. For example, a MySQL/MariaDB DBMS may use mysqldump. 85 | 86 | Additionally you have to backup the place where the documents are stored. You 87 | can configure this in config/settings.yml. To restore, just put the documents back in that location. 88 | 89 | ## Routes Documentation 90 | 91 | To learn about the routes the API offers, run the following command: ``rake routes`` 92 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /app/assets/config/manifest.js: -------------------------------------------------------------------------------- 1 | //= link_tree ../images 2 | //= link_directory ../javascripts .js 3 | //= link_directory ../stylesheets .css 4 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonashellmann/everydocs-core/fcff6b56ab98a57c3202ed37c10446657396de49/app/assets/images/.keep -------------------------------------------------------------------------------- /app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 5 | // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // compiled file. 9 | // 10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require jquery 14 | //= require jquery_ujs 15 | //= require turbolinks 16 | //= require_tree . 17 | -------------------------------------------------------------------------------- /app/assets/javascripts/authentication.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /app/assets/javascripts/documents.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /app/assets/javascripts/folders.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /app/assets/javascripts/people.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /app/assets/javascripts/search.js: -------------------------------------------------------------------------------- 1 | // Place all the behaviors and hooks related to the matching controller here. 2 | // All this logic will automatically be available in application.js. 3 | -------------------------------------------------------------------------------- /app/assets/javascripts/states.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /app/assets/javascripts/tags.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /app/assets/javascripts/users.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /app/assets/javascripts/welcome.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any styles 10 | * defined in the other CSS/SCSS files in this directory. It is generally better to create a new 11 | * file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /app/assets/stylesheets/authentication.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the authentication controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/documents.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the documents controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/folders.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the folders controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/people.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the people controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/search.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the Search controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/states.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the states controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/tags.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the tags controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/users.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the users controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/welcome.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the welcome controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /app/auth/authenticate_user.rb: -------------------------------------------------------------------------------- 1 | class AuthenticateUser 2 | def initialize(email, password) 3 | @email = email 4 | @password = password 5 | end 6 | 7 | # Service entry point 8 | def call 9 | JsonWebToken.encode(user_id: user.id) if user 10 | end 11 | 12 | private 13 | 14 | attr_reader :email, :password 15 | 16 | # verify user credentials 17 | def user 18 | user = User.find_by(email: email) 19 | return user if user && user.authenticate(password) 20 | # raise Authentication error if credentials are invalid 21 | raise(ExceptionHandler::AuthenticationError, Message.invalid_credentials) 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /app/auth/authorize_api_request.rb: -------------------------------------------------------------------------------- 1 | class AuthorizeApiRequest 2 | def initialize(headers = {}) 3 | @headers = headers 4 | end 5 | 6 | # Service entry point - return valid user object 7 | def call 8 | { 9 | user: user 10 | } 11 | end 12 | 13 | private 14 | 15 | attr_reader :headers 16 | 17 | def user 18 | # check if user is in the database 19 | # memoize user object 20 | @user ||= User.find(decoded_auth_token[:user_id]) if decoded_auth_token 21 | # handle user not found 22 | rescue ActiveRecord::RecordNotFound => e 23 | # raise custom error 24 | raise( 25 | ExceptionHandler::InvalidToken, 26 | ("#{Message.invalid_token} #{e.message}") 27 | ) 28 | end 29 | 30 | # decode authentication token 31 | def decoded_auth_token 32 | @decoded_auth_token ||= JsonWebToken.decode(http_auth_header) 33 | end 34 | 35 | # check for token in `Authorization` header 36 | def http_auth_header 37 | if headers['Authorization'].present? 38 | return headers['Authorization'].split(' ').last 39 | end 40 | raise(ExceptionHandler::MissingToken, Message.missing_token) 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks 3 | protect_from_forgery with: :exception 4 | 5 | include Response 6 | include ExceptionHandler 7 | 8 | # called before every action on controllers 9 | before_action :authorize_request 10 | attr_reader :current_user 11 | 12 | skip_before_action :verify_authenticity_token 13 | 14 | private 15 | 16 | # Check for valid request token and return user 17 | def authorize_request 18 | @current_user = (AuthorizeApiRequest.new(request.headers).call)[:user] 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /app/controllers/authentication_controller.rb: -------------------------------------------------------------------------------- 1 | class AuthenticationController < ApplicationController 2 | skip_before_action :authorize_request, only: :authenticate 3 | 4 | # return auth token once user is authenticated 5 | def authenticate 6 | auth_token = 7 | AuthenticateUser.new(auth_params[:email], auth_params[:password]).call 8 | json_response(auth_token: auth_token) 9 | end 10 | 11 | private 12 | 13 | def auth_params 14 | params.permit(:email, :password) 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonashellmann/everydocs-core/fcff6b56ab98a57c3202ed37c10446657396de49/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /app/controllers/concerns/exception_handler.rb: -------------------------------------------------------------------------------- 1 | module ExceptionHandler 2 | extend ActiveSupport::Concern 3 | 4 | # Define custom error subclasses - rescue catches `StandardErrors` 5 | class AuthenticationError < StandardError; end 6 | class MissingToken < StandardError; end 7 | class InvalidToken < StandardError; end 8 | 9 | included do 10 | # Define custom handlers 11 | rescue_from ActiveRecord::RecordInvalid, with: :four_twenty_two 12 | rescue_from ExceptionHandler::AuthenticationError, with: :unauthorized_request 13 | rescue_from ExceptionHandler::MissingToken, with: :four_twenty_two 14 | rescue_from ExceptionHandler::InvalidToken, with: :four_twenty_two 15 | 16 | rescue_from ActiveRecord::RecordNotFound do |e| 17 | json_response({ message: e.message }, :not_found) 18 | end 19 | end 20 | 21 | private 22 | 23 | # JSON response with message; Status code 422 - unprocessable entity 24 | def four_twenty_two(e) 25 | json_response({ message: e.message }, :unprocessable_entity) 26 | end 27 | 28 | # JSON response with message; Status code 401 - Unauthorized 29 | def unauthorized_request(e) 30 | json_response({ message: e.message }, :unauthorized) 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /app/controllers/concerns/response.rb: -------------------------------------------------------------------------------- 1 | module Response 2 | def json_response(object, status = :ok) 3 | render json: object, status: status 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /app/controllers/documents_controller.rb: -------------------------------------------------------------------------------- 1 | class DocumentsController < ApplicationController 2 | before_action :set_document, only: [:show, :download, :update, :destroy] 3 | before_action :set_documents, only: [:index, :page_count] 4 | 5 | # GET /documents 6 | def index 7 | @start_index = 0 8 | if (!params[:page].blank?) 9 | @start_index = (convert_to_int(params[:page]) - 1) * 20 10 | end 11 | @end_index = @start_index + 19 12 | @documents = @documents[@start_index..@end_index] 13 | 14 | json_response(@documents) 15 | end 16 | 17 | # POST /documents 18 | def create 19 | @file = params[:document] 20 | @file_text = "" 21 | @encrypted = current_user.encryption_actived_flag? and current_user.secret_key.present? 22 | 23 | if @file.blank? 24 | @file_name = nil 25 | else 26 | @file_name = SecureRandom.uuid + '.pdf' 27 | 28 | if @encrypted 29 | lockbox = Lockbox.new(key: current_user.secret_key) 30 | 31 | data = @file.read 32 | encrypted_data = lockbox.encrypt(data) 33 | File.write(Settings.document_folder + @file_name, encrypted_data, mode: 'w+b') 34 | else 35 | File.write(Settings.document_folder + @file_name, data, mode: 'w+b') 36 | 37 | begin 38 | reader = PDF::Reader.new(Settings.document_folder + @file_name) 39 | reader.pages.each do |page| 40 | @file_text = @file_text + page.text 41 | end 42 | 43 | @file_text.delete!("\r\n") 44 | @file_text.delete!("\n") 45 | @file_text.delete!(' ') 46 | 47 | if @file_text.bytesize > 65535 48 | @file_text = "" 49 | end 50 | rescue PDF::Reader::MalformedPDFError, PDF::Reader::EncryptedPDFError 51 | @file_text = "" 52 | end 53 | end 54 | end 55 | 56 | @folder = params[:folder].blank? ? nil : Folder.find(params[:folder]) 57 | @state = params[:state].blank? ? nil : State.find(params[:state]) 58 | @person = params[:person].blank? ? nil : Person.find(params[:person]) 59 | 60 | @params = { 61 | "title" => params[:title], 62 | "description" => params[:description], 63 | "document_date" => params[:document_date], 64 | "document_text" => @file_text, 65 | "folder" => @folder, 66 | "state" => @state, 67 | "person" => @person, 68 | "document_url" => @file_name, 69 | "encrypted_flag" => @encrypted 70 | } 71 | 72 | @document = current_user.documents.create!(@params) 73 | json_response(@document, :created) 74 | end 75 | 76 | # GET /documents/:id 77 | def show 78 | json_response(@document) 79 | end 80 | 81 | # GET /documents/file/:id 82 | def download 83 | if @document.encrypted_flag 84 | lockbox = Lockbox.new(key: current_user.secret_key) 85 | decrypted_data = lockbox.decrypt(File.read(Settings.document_folder + @document.document_url)) 86 | send_data decrypted_data, :filename=>@document.title + ".pdf", :type=>"application/pdf", :x_sendfile=>true, :disposition=>'attachement' 87 | else 88 | send_file Settings.document_folder + @document.document_url, :filename=>@document.title + ".pdf", :type=>"application/pdf", :x_sendfile=>true, :disposition=>'attachment' 89 | end 90 | end 91 | 92 | # PUT /documents/:id 93 | def update 94 | @folder = params[:folder].blank? ? nil : Folder.find(params[:folder]) 95 | @state = params[:state].blank? ? nil : State.find(params[:state]) 96 | @person = params[:person].blank? ? nil : Person.find(params[:person]) 97 | 98 | @params = { 99 | "title" => params[:title], 100 | "description" => params[:description], 101 | "document_date" => params[:document_date], 102 | "folder" => @folder, 103 | "state" => @state, 104 | "person" => @person, 105 | } 106 | 107 | @document.update(@params) 108 | head :no_content 109 | end 110 | 111 | # DELETE /documents/:id 112 | def destroy 113 | @filename = Settings.document_folder + @document.document_url 114 | File.delete(@filename) if File.exist?(@filename) 115 | 116 | @document.destroy 117 | head :no_content 118 | end 119 | 120 | # GET /documents/pages 121 | def page_count 122 | @document_count = @documents.length() 123 | @page_count = (@document_count/20.to_f).ceil 124 | json_response(page_count: @page_count) 125 | end 126 | 127 | private 128 | 129 | def convert_to_int(string) 130 | num = string.to_i 131 | num if num.to_s == string 132 | end 133 | 134 | def set_document 135 | @document = Document.find(params[:id]) 136 | end 137 | 138 | def set_documents 139 | @documents = current_user.documents.order(document_date: :desc) 140 | 141 | if (!params[:folder_filter].blank?) 142 | @documents = @documents.select { |d| d.folder_id == convert_to_int(params[:folder_filter])} 143 | end 144 | if (!params[:state_filter].blank?) 145 | @documents = @documents.select { |d| d.state_id == convert_to_int(params[:state_filter])} 146 | end 147 | if (!params[:person_filter].blank?) 148 | @documents = @documents.select { |d| d.person_id == convert_to_int(params[:person_filter])} 149 | end 150 | if (!params[:search].blank?) 151 | @search = params[:search].to_s.downcase.delete(' ') 152 | @documents = @documents.select { |d| (d.title.downcase.delete(' ').include?(@search) or (!d.description.nil? and d.description.downcase.delete(' ').include?(@search)) or (!d.document_text.nil? and d.document_text.downcase.delete(' ').include?(@search)))} 153 | end 154 | end 155 | end 156 | -------------------------------------------------------------------------------- /app/controllers/folders_controller.rb: -------------------------------------------------------------------------------- 1 | class FoldersController < ApplicationController 2 | before_action :set_folder, only: [:show, :update, :destroy] 3 | 4 | # GET /folders 5 | def index 6 | @folders = current_user.folders.where("folder_id is null") 7 | json_response(@folders) 8 | end 9 | 10 | # GET /folders-all 11 | def all 12 | @folders = current_user.folders 13 | json_response(@folders) 14 | end 15 | 16 | # POST /folders 17 | def create 18 | @parent_folder = params[:folder].blank? ? nil : Folder.find(params[:folder]) 19 | @params = { 20 | "name" => params[:name], 21 | "folder" => @parent_folder 22 | } 23 | 24 | @folder = current_user.folders.create!(@params) 25 | json_response(@folder, :created) 26 | end 27 | 28 | # GET /folders/:id 29 | def show 30 | json_response(@folder) 31 | end 32 | 33 | # PUT /folders/:id 34 | def update 35 | @parent_folder = params[:folder].blank? ? nil : Folder.find(params[:folder]) 36 | @params = { 37 | "name" => params[:name], 38 | "folder" => @parent_folder 39 | } 40 | 41 | @folder.update(@params) 42 | head :no_content 43 | end 44 | 45 | # DELETE /folders/:id 46 | def destroy 47 | @folder.destroy 48 | head :no_content 49 | end 50 | 51 | private 52 | 53 | def set_folder 54 | @folder = Folder.find(params[:id]) 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /app/controllers/people_controller.rb: -------------------------------------------------------------------------------- 1 | class PeopleController < ApplicationController 2 | before_action :set_person, only: [:show, :update, :destroy] 3 | 4 | # GET /people 5 | def index 6 | @people = current_user.people 7 | json_response(@people) 8 | end 9 | 10 | # POST /people 11 | def create 12 | @person = current_user.people.create!(person_params) 13 | json_response(@person, :created) 14 | end 15 | 16 | # GET /people/:id 17 | def show 18 | json_response(@person) 19 | end 20 | 21 | # PUT /people/:id 22 | def update 23 | @person.update(person_params) 24 | head :no_content 25 | end 26 | 27 | # DELETE /people/:id 28 | def destroy 29 | @person.destroy 30 | head :no_content 31 | end 32 | 33 | private 34 | 35 | def person_params 36 | params.permit(:name, :user) 37 | end 38 | 39 | def set_person 40 | @person = Person.find(params[:id]) 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /app/controllers/search_controller.rb: -------------------------------------------------------------------------------- 1 | class SearchController < ApplicationController 2 | 3 | #GET /search/suggestions/:text 4 | def suggestions 5 | @encoded_html = Nokogiri::HTML.parse params[:text] 6 | @text = @encoded_html.text 7 | @result = current_user.documents.select("title, count(*) as count").where("title LIKE ?", "%#{@text}%").group("title").order(title: :asc) 8 | 9 | @json = '' 10 | @result.each do |r| 11 | @json = @json + '{title: ' + r.title + ', count: ' + r.count.to_s + '},' 12 | end 13 | @json = '[' + @json + ']' 14 | 15 | render json: @json 16 | end 17 | 18 | end 19 | -------------------------------------------------------------------------------- /app/controllers/states_controller.rb: -------------------------------------------------------------------------------- 1 | class StatesController < ApplicationController 2 | before_action :set_state, only: [:show, :update, :destroy] 3 | 4 | # GET /states 5 | def index 6 | @states = State.where("id >= ?", 0) 7 | json_response(@states) 8 | end 9 | 10 | # POST /states 11 | def create 12 | @state = current_user.states.create!(state_params) 13 | json_response(@state, :created) 14 | end 15 | 16 | # GET /states/:id 17 | def show 18 | json_response(@state) 19 | end 20 | 21 | # PUT /states/:id 22 | def update 23 | @state.update(state_params) 24 | head :no_content 25 | end 26 | 27 | # DELETE /states/:id 28 | def destroy 29 | @state.destroy 30 | head :no_content 31 | end 32 | 33 | private 34 | 35 | def state_params 36 | params.permit(:name) 37 | end 38 | 39 | def set_state 40 | @state = State.find(params[:id]) 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /app/controllers/tags_controller.rb: -------------------------------------------------------------------------------- 1 | class TagsController < ApplicationController 2 | before_action :set_tag, only: [:show, :update, :destroy] 3 | 4 | # GET /tags 5 | def index 6 | @tags = current_user.tags 7 | json_response(@tags) 8 | end 9 | 10 | # POST /tags 11 | def create 12 | @tag = current_user.tags.create!(tag_params) 13 | json_response(@tag, :created) 14 | end 15 | 16 | # GET /tags/:id 17 | def show 18 | json_response(@tag) 19 | end 20 | 21 | # PUT /tags/:id 22 | def update 23 | @tag.update(tag_params) 24 | head :no_content 25 | end 26 | 27 | # DELETE /tags/:id 28 | def destroy 29 | @tag.destroy 30 | head :no_content 31 | end 32 | 33 | private 34 | 35 | def tag_params 36 | params.permit(:name, :user, :color) 37 | end 38 | 39 | def set_tag 40 | @tag = Tag.find(params[:id]) 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /app/controllers/users_controller.rb: -------------------------------------------------------------------------------- 1 | class UsersController < ApplicationController 2 | skip_before_action :authorize_request, only: :create 3 | 4 | # return authenticated token upon signup 5 | def create 6 | key = Lockbox.generate_key 7 | my_user_params = user_params.to_h.merge(secret_key: key).merge(encryption_actived_flag: true) 8 | user = User.create!(my_user_params) 9 | auth_token = AuthenticateUser.new(user.email, user.password).call 10 | response = { message: Message.account_created, auth_token: auth_token } 11 | json_response(response, :created) 12 | 13 | rescue ActiveRecord::RecordNotUnique 14 | json_response({message: 'There is already an account with this email!'}) 15 | end 16 | 17 | private 18 | 19 | def user_params 20 | params.permit(:name, :email, :password, :password_confirmation) 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /app/controllers/version_controller.rb: -------------------------------------------------------------------------------- 1 | class VersionController < ApplicationController 2 | skip_before_action :authorize_request 3 | 4 | # GET /version 5 | def version 6 | version = '1.5.20' 7 | json_response(version: version) 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /app/controllers/welcome_controller.rb: -------------------------------------------------------------------------------- 1 | class WelcomeController < ApplicationController 2 | skip_before_action :authorize_request 3 | 4 | def index 5 | json_response({ message: "Welcome to EveryDocs. Visit https://github.com/jonashellmann/everydocs-core/ to learn more about this application."}) 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/authentication_helper.rb: -------------------------------------------------------------------------------- 1 | module AuthenticationHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/documents_helper.rb: -------------------------------------------------------------------------------- 1 | module DocumentsHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/folders_helper.rb: -------------------------------------------------------------------------------- 1 | module FoldersHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/people_helper.rb: -------------------------------------------------------------------------------- 1 | module PeopleHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/search_helper.rb: -------------------------------------------------------------------------------- 1 | module SearchHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/states_helper.rb: -------------------------------------------------------------------------------- 1 | module StatesHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/tags_helper.rb: -------------------------------------------------------------------------------- 1 | module TagsHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/users_helper.rb: -------------------------------------------------------------------------------- 1 | module UsersHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/welcome_helper.rb: -------------------------------------------------------------------------------- 1 | module WelcomeHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/lib/json_web_token.rb: -------------------------------------------------------------------------------- 1 | class JsonWebToken 2 | # secret to encode and decode token 3 | HMAC_SECRET = Rails.configuration.secrets.secret_key_base 4 | 5 | def self.encode(payload, exp = 24.hours.from_now) 6 | # set expiry to 24 hours from creation time 7 | payload[:exp] = exp.to_i 8 | # sign token with application secret 9 | JWT.encode(payload, HMAC_SECRET) 10 | end 11 | 12 | def self.decode(token) 13 | # get payload; first index in decoded Array 14 | body = JWT.decode(token, HMAC_SECRET)[0] 15 | HashWithIndifferentAccess.new body 16 | # rescue from all decode errors 17 | rescue JWT::DecodeError => e 18 | # raise custom error to be handled by custom handler 19 | raise ExceptionHandler::InvalidToken, e.message 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /app/lib/message.rb: -------------------------------------------------------------------------------- 1 | class Message 2 | def self.not_found(record = 'record') 3 | "Sorry, #{record} not found." 4 | end 5 | 6 | def self.invalid_credentials 7 | 'Invalid credentials' 8 | end 9 | 10 | def self.invalid_token 11 | 'Invalid token' 12 | end 13 | 14 | def self.missing_token 15 | 'Missing token' 16 | end 17 | 18 | def self.unauthorized 19 | 'Unauthorized request' 20 | end 21 | 22 | def self.account_created 23 | 'Account created successfully' 24 | end 25 | 26 | def self.account_not_created 27 | 'Account could not be created' 28 | end 29 | 30 | def self.expired_token 31 | 'Sorry, your token has expired. Please login to continue.' 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /app/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonashellmann/everydocs-core/fcff6b56ab98a57c3202ed37c10446657396de49/app/mailers/.keep -------------------------------------------------------------------------------- /app/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonashellmann/everydocs-core/fcff6b56ab98a57c3202ed37c10446657396de49/app/models/.keep -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonashellmann/everydocs-core/fcff6b56ab98a57c3202ed37c10446657396de49/app/models/concerns/.keep -------------------------------------------------------------------------------- /app/models/document.rb: -------------------------------------------------------------------------------- 1 | class Document < ActiveRecord::Base 2 | belongs_to :folder, optional: true 3 | belongs_to :user 4 | belongs_to :state, optional: true 5 | belongs_to :person, optional: true 6 | 7 | has_many :documenttags 8 | has_many :tags, through: :documenttags 9 | 10 | validates_presence_of :title, :document_date, :user, :document_url 11 | 12 | def as_json(_options = {}) 13 | super include: { 14 | folder: {only: [:id, :name]}, 15 | state: {only: [:id, :name]}, 16 | tags: {only: [:id, :name]}, 17 | user: {only: [:id, :name]}, 18 | person: {only: [:id, :name]}, 19 | } 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /app/models/documenttag.rb: -------------------------------------------------------------------------------- 1 | class Documenttag < ActiveRecord::Base 2 | belongs_to :document 3 | belongs_to :tag 4 | 5 | validates_presence_of :document, :tag 6 | end 7 | -------------------------------------------------------------------------------- /app/models/folder.rb: -------------------------------------------------------------------------------- 1 | class Folder < ActiveRecord::Base 2 | belongs_to :folder 3 | belongs_to :user 4 | 5 | has_many :documents, dependent: :destroy 6 | has_many :folders, dependent: :destroy 7 | 8 | def as_json(_options = {}) 9 | super include: { 10 | folders: { 11 | include: { 12 | folders: { 13 | include: { 14 | folders: { 15 | include: { 16 | folders: {} 17 | } 18 | } 19 | } 20 | } 21 | } 22 | }, 23 | } 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /app/models/person.rb: -------------------------------------------------------------------------------- 1 | class Person < ActiveRecord::Base 2 | belongs_to :user 3 | 4 | has_many :documents, dependent: :nullify 5 | 6 | validates_presence_of :name 7 | end 8 | -------------------------------------------------------------------------------- /app/models/state.rb: -------------------------------------------------------------------------------- 1 | class State < ActiveRecord::Base 2 | belongs_to :user 3 | 4 | has_many :documents 5 | 6 | validates_presence_of :name 7 | end 8 | -------------------------------------------------------------------------------- /app/models/tag.rb: -------------------------------------------------------------------------------- 1 | class Tag < ActiveRecord::Base 2 | belongs_to :user 3 | 4 | has_many :documenttags, dependent: :nullify 5 | has_many :documents, through: :documenttags 6 | 7 | validates_presence_of :name 8 | end 9 | -------------------------------------------------------------------------------- /app/models/user.rb: -------------------------------------------------------------------------------- 1 | class User < ActiveRecord::Base 2 | has_secure_password 3 | 4 | has_many :documents 5 | has_many :folders 6 | has_many :tags 7 | has_many :people 8 | has_many :states 9 | 10 | validates_presence_of :name, :email, :password_digest 11 | end 12 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EverydocsCore 5 | <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> 6 | <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> 7 | <%= csrf_meta_tags %> 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /bin/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | rake db:migrate 5 | 6 | exec "$@" 7 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | APP_PATH = File.expand_path('../../config/application', __FILE__) 8 | require_relative '../config/boot' 9 | require 'rails/commands' 10 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | require_relative '../config/boot' 8 | require 'rake' 9 | Rake.application.run 10 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | 4 | # path to your application root. 5 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 6 | 7 | Dir.chdir APP_ROOT do 8 | # This script is a starting point to setup your application. 9 | # Add necessary setup steps to this file: 10 | 11 | puts "== Installing dependencies ==" 12 | system "gem install bundler --conservative" 13 | system "bundle check || bundle install" 14 | 15 | # puts "\n== Copying sample files ==" 16 | # unless File.exist?("config/database.yml") 17 | # system "cp config/database.yml.sample config/database.yml" 18 | # end 19 | 20 | puts "\n== Preparing database ==" 21 | system "bin/rake db:setup" 22 | 23 | puts "\n== Removing old logs and tempfiles ==" 24 | system "rm -f log/*" 25 | system "rm -rf tmp/cache" 26 | 27 | puts "\n== Restarting application server ==" 28 | system "touch tmp/restart.txt" 29 | end 30 | -------------------------------------------------------------------------------- /bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This file loads spring without using Bundler, in order to be fast. 4 | # It gets overwritten when you run the `spring binstub` command. 5 | 6 | unless defined?(Spring) 7 | require 'rubygems' 8 | require 'bundler' 9 | 10 | lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) 11 | spring = lockfile.specs.detect { |spec| spec.name == "spring" } 12 | if spring 13 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path 14 | gem 'spring', spring.version 15 | require 'spring/binstub' 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | require 'rails/all' 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | 9 | module EverydocsCore 10 | class Application < Rails::Application 11 | # Settings in config/environments/* take precedence over those specified here. 12 | # Application configuration should go into files in config/initializers 13 | # -- all .rb files in that directory are automatically loaded. 14 | 15 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 16 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 17 | # config.time_zone = 'Central Time (US & Canada)' 18 | 19 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 20 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 21 | # config.i18n.default_locale = :de 22 | 23 | # Do not swallow errors in after_commit/after_rollback callbacks. 24 | # config.active_record.raise_in_transactional_callbacks = true 25 | 26 | # Deprecated since Rails version 6 27 | # Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true 28 | config.secrets = config_for(:secrets) 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem 'sqlite3' 6 | # 7 | default: &default 8 | adapter: sqlite3 9 | pool: 5 10 | timeout: 5000 11 | 12 | development: 13 | <<: *default 14 | database: db/development.sqlite3 15 | 16 | # Warning: The database defined as "test" will be erased and 17 | # re-generated from your development database when you run "rake". 18 | # Do not set this db to the same as development or production. 19 | test: 20 | <<: *default 21 | database: db/test.sqlite3 22 | 23 | production: 24 | adapter: <%= ENV['EVERYDOCS_DB_ADAPTER'] %> 25 | database: <%= ENV['EVERYDOCS_DB_NAME'] %> 26 | username: <%= ENV['EVERYDOCS_DB_USER'] %> 27 | password: <%= ENV['EVERYDOCS_DB_PASSWORD'] %> 28 | host: <%= ENV['EVERYDOCS_DB_HOST'] %> 29 | port: <%= ENV['EVERYDOCS_DB_PORT'] %> 30 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports and disable caching. 13 | config.consider_all_requests_local = true 14 | config.action_controller.perform_caching = false 15 | 16 | # Don't care if the mailer can't send. 17 | config.action_mailer.raise_delivery_errors = false 18 | 19 | # Print deprecation notices to the Rails logger. 20 | config.active_support.deprecation = :log 21 | 22 | # Raise an error on page load if there are pending migrations. 23 | config.active_record.migration_error = :page_load 24 | 25 | # Debug mode disables concatenation and preprocessing of assets. 26 | # This option may cause significant delays in view rendering with a large 27 | # number of complex assets. 28 | config.assets.debug = true 29 | 30 | # Asset digests allow you to set far-future HTTP expiration dates on all assets, 31 | # yet still be able to expire them through the digest params. 32 | config.assets.digest = true 33 | 34 | # Adds additional error checking when serving assets at runtime. 35 | # Checks for improperly declared sprockets dependencies. 36 | # Raises helpful error messages. 37 | config.assets.raise_runtime_errors = true 38 | 39 | # Raises error for missing translations 40 | # config.action_view.raise_on_missing_translations = true 41 | 42 | config.web_console.whiny_requests = false 43 | end 44 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Enable Rack::Cache to put a simple HTTP cache in front of your application 18 | # Add `rack-cache` to your Gemfile before enabling this. 19 | # For large-scale production use, consider using a caching reverse proxy like 20 | # NGINX, varnish or squid. 21 | # config.action_dispatch.rack_cache = true 22 | 23 | # Disable serving static files from the `/public` folder by default since 24 | # Apache or NGINX already handles this. 25 | config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? 26 | 27 | # Compress JavaScripts and CSS. 28 | config.assets.js_compressor = :uglifier 29 | # config.assets.css_compressor = :sass 30 | 31 | # Do not fallback to assets pipeline if a precompiled asset is missed. 32 | config.assets.compile = false 33 | 34 | # Asset digests allow you to set far-future HTTP expiration dates on all assets, 35 | # yet still be able to expire them through the digest params. 36 | config.assets.digest = true 37 | 38 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 39 | 40 | # Specifies the header that your server uses for sending files. 41 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 42 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 43 | 44 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 45 | # config.force_ssl = true 46 | 47 | # Use the lowest log level to ensure availability of diagnostic information 48 | # when problems arise. 49 | config.log_level = :debug 50 | 51 | # Prepend all log lines with the following tags. 52 | # config.log_tags = [ :subdomain, :uuid ] 53 | 54 | # Use a different logger for distributed setups. 55 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 56 | 57 | # Use a different cache store in production. 58 | # config.cache_store = :mem_cache_store 59 | 60 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 61 | # config.action_controller.asset_host = 'http://assets.example.com' 62 | 63 | # Ignore bad email addresses and do not raise email delivery errors. 64 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 65 | # config.action_mailer.raise_delivery_errors = false 66 | 67 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 68 | # the I18n.default_locale when a translation cannot be found). 69 | config.i18n.fallbacks = true 70 | 71 | # Send deprecation notices to registered listeners. 72 | config.active_support.deprecation = :notify 73 | 74 | # Use default logging formatter so that PID and timestamp are not suppressed. 75 | config.log_formatter = ::Logger::Formatter.new 76 | 77 | # Do not dump schema after migrations. 78 | config.active_record.dump_schema_after_migration = false 79 | end 80 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = false 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure static file server for tests with Cache-Control for performance. 16 | config.serve_static_files = true 17 | config.static_cache_control = 'public, max-age=3600' 18 | 19 | # Show full error reports and disable caching. 20 | config.consider_all_requests_local = true 21 | config.action_controller.perform_caching = false 22 | 23 | # Raise exceptions instead of rendering exception templates. 24 | config.action_dispatch.show_exceptions = false 25 | 26 | # Disable request forgery protection in test environment. 27 | config.action_controller.allow_forgery_protection = false 28 | 29 | # Tell Action Mailer not to deliver emails to the real world. 30 | # The :test delivery method accumulates sent emails in the 31 | # ActionMailer::Base.deliveries array. 32 | config.action_mailer.delivery_method = :test 33 | 34 | # Randomize the order test cases are executed. 35 | config.active_support.test_order = :random 36 | 37 | # Print deprecation notices to the stderr. 38 | config.active_support.deprecation = :stderr 39 | 40 | # Raises error for missing translations 41 | # config.action_view.raise_on_missing_translations = true 42 | end 43 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = '1.0' 5 | 6 | # Add additional assets to the asset load path 7 | # Rails.application.config.assets.paths << Emoji.images_path 8 | 9 | # Precompile additional assets. 10 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 11 | # Rails.application.config.assets.precompile += %w( search.js ) 12 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json 4 | -------------------------------------------------------------------------------- /config/initializers/cors.rb: -------------------------------------------------------------------------------- 1 | Rails.application.config.middleware.insert_before 0, Rack::Cors do 2 | allow do 3 | origins '*' 4 | resource '*', headers: :any, methods: :any 5 | end 6 | end -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_everydocs-core_session' 4 | -------------------------------------------------------------------------------- /config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters) 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # To learn more, please read the Rails Internationalization guide 20 | # available at http://guides.rubyonrails.org/i18n.html. 21 | 22 | en: 23 | hello: "Hello world" 24 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | root 'welcome#index' 3 | 4 | post 'auth/login', to: 'authentication#authenticate' 5 | post 'signup', to: 'users#create' 6 | 7 | get 'documents/file/:id', to: 'documents#download' 8 | get 'documents/pages', to: 'documents#page_count' 9 | resources :documents 10 | 11 | resources :folders 12 | get 'folders-all', to: 'folders#all' 13 | 14 | resources :states 15 | resources :people 16 | resources :tags 17 | 18 | get 'search/suggestions/:text', to: 'search#suggestions' 19 | get 'version', to: 'version#version' 20 | end 21 | -------------------------------------------------------------------------------- /config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rake secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | development: 14 | secret_key_base: <%= ENV["SECRET_KEY_BASE_DEV"] %> 15 | 16 | test: 17 | secret_key_base: <%= ENV["SECRET_KEY_BASE_TEST"] %> 18 | 19 | # Do not keep production secrets in the repository, 20 | # instead read values from the environment. 21 | production: 22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 23 | -------------------------------------------------------------------------------- /config/settings.yml: -------------------------------------------------------------------------------- 1 | document_folder: /var/everydocs-files/ 2 | -------------------------------------------------------------------------------- /config/storage.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonashellmann/everydocs-core/fcff6b56ab98a57c3202ed37c10446657396de49/config/storage.yml -------------------------------------------------------------------------------- /db/migrate/20190525164329_create_states.rb: -------------------------------------------------------------------------------- 1 | class CreateStates < ActiveRecord::Migration[4.2] 2 | def change 3 | create_table :states do |t| 4 | t.string :name 5 | t.references :user 6 | t.timestamps null: false 7 | end 8 | add_index :states, :name, unique: true 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /db/migrate/20190525164336_create_users.rb: -------------------------------------------------------------------------------- 1 | class CreateUsers < ActiveRecord::Migration[4.2] 2 | def change 3 | create_table :users do |t| 4 | t.string :name 5 | t.string :password_digest 6 | t.string :email 7 | 8 | t.timestamps null: false 9 | end 10 | add_index :users, :email, unique: true 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /db/migrate/20190525164530_create_folders.rb: -------------------------------------------------------------------------------- 1 | class CreateFolders < ActiveRecord::Migration[4.2] 2 | def change 3 | create_table :folders do |t| 4 | t.string :name 5 | t.references :folder, index: true, foreign_key: true 6 | t.references :user, index: true, foreign_key: true 7 | 8 | t.timestamps null: false 9 | end 10 | add_index :folders, :name, unique: true 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /db/migrate/20190528071549_create_tags.rb: -------------------------------------------------------------------------------- 1 | class CreateTags < ActiveRecord::Migration[4.2] 2 | def change 3 | create_table :tags do |t| 4 | t.string :name 5 | t.references :user 6 | t.string :color 7 | 8 | t.timestamps null: false 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20190528071703_create_people.rb: -------------------------------------------------------------------------------- 1 | class CreatePeople < ActiveRecord::Migration[4.2] 2 | def change 3 | create_table :people do |t| 4 | t.string :name 5 | t.references :user 6 | 7 | t.timestamps null: false 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /db/migrate/20190528071704_create_documents.rb: -------------------------------------------------------------------------------- 1 | class CreateDocuments < ActiveRecord::Migration[4.2] 2 | def change 3 | create_table :documents do |t| 4 | t.string :title 5 | t.text :description 6 | t.date :document_date 7 | t.string :document_url 8 | t.decimal :version 9 | t.text :document_text 10 | t.references :folder, index: true, foreign_key: {on_delete: :nullify} 11 | t.references :user, index: true, foreign_key: {on_delete: :cascade} 12 | t.references :state, index: true, foreign_key: {on_delete: :nullify} 13 | t.references :person, index: true, foreign_key: {on_delete: :nullify} 14 | 15 | t.timestamps null: false 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /db/migrate/20190528071907_create_documenttags.rb: -------------------------------------------------------------------------------- 1 | class CreateDocumenttags < ActiveRecord::Migration[4.2] 2 | def change 3 | create_table :documenttags do |t| 4 | t.references :document, index: true, foreign_key: true 5 | t.references :tag, index: true, foreign_key: true 6 | 7 | t.timestamps null: false 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /db/migrate/20230731162630_change_index_on_folders.rb: -------------------------------------------------------------------------------- 1 | class ChangeIndexOnFolders < ActiveRecord::Migration[7.0] 2 | def change 3 | remove_index :folders, name: "index_folders_on_name" 4 | add_index :folders, [:name, :user_id], unique: true 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /db/migrate/20230731163018_change_index_on_states.rb: -------------------------------------------------------------------------------- 1 | class ChangeIndexOnStates < ActiveRecord::Migration[7.0] 2 | def change 3 | remove_index :states, name: "index_states_on_name" 4 | add_index :states, [:name, :user_id], unique: true 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /db/migrate/20240325214102_change_index_on_folders_again.rb: -------------------------------------------------------------------------------- 1 | class ChangeIndexOnFoldersAgain < ActiveRecord::Migration[7.0] 2 | def change 3 | remove_index :folders, name: "index_folders_on_name_and_user_id" 4 | add_index :folders, [:name, :user_id, :folder_id], unique: true 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /db/migrate/20240331170409_add_secret_key_to_users.rb: -------------------------------------------------------------------------------- 1 | class AddSecretKeyToUsers < ActiveRecord::Migration[7.1] 2 | def change 3 | add_column :users, :secret_key, :string, default: nil 4 | add_column :users, :encryption_actived_flag, :boolean, default: false 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /db/migrate/20240331170416_add_encrypted_flag_to_documents.rb: -------------------------------------------------------------------------------- 1 | class AddEncryptedFlagToDocuments < ActiveRecord::Migration[7.1] 2 | def change 3 | add_column :documents, :encrypted_flag, :boolean, default: false 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # This file is auto-generated from the current state of the database. Instead 2 | # of editing this file, please use the migrations feature of Active Record to 3 | # incrementally modify your database, and then regenerate this schema definition. 4 | # 5 | # This file is the source Rails uses to define your schema when running `rails 6 | # db:schema:load`. When creating a new database, `rails db:schema:load` tends to 7 | # be faster and is potentially less error prone than running all of your 8 | # migrations from scratch. Old migrations may fail to apply correctly if those 9 | # migrations use external dependencies or application code. 10 | # 11 | # It's strongly recommended that you check this file into your version control system. 12 | 13 | ActiveRecord::Schema.define(version: 2019_05_28_071907) do 14 | 15 | create_table "documents", force: :cascade do |t| 16 | t.string "title" 17 | t.text "description" 18 | t.date "document_date" 19 | t.string "document_url" 20 | t.decimal "version" 21 | t.text "document_text" 22 | t.integer "folder_id" 23 | t.integer "user_id" 24 | t.integer "state_id" 25 | t.integer "person_id" 26 | t.datetime "created_at", null: false 27 | t.datetime "updated_at", null: false 28 | t.index ["folder_id"], name: "index_documents_on_folder_id" 29 | t.index ["person_id"], name: "index_documents_on_person_id" 30 | t.index ["state_id"], name: "index_documents_on_state_id" 31 | t.index ["user_id"], name: "index_documents_on_user_id" 32 | end 33 | 34 | create_table "documenttags", force: :cascade do |t| 35 | t.integer "document_id" 36 | t.integer "tag_id" 37 | t.datetime "created_at", null: false 38 | t.datetime "updated_at", null: false 39 | t.index ["document_id"], name: "index_documenttags_on_document_id" 40 | t.index ["tag_id"], name: "index_documenttags_on_tag_id" 41 | end 42 | 43 | create_table "folders", force: :cascade do |t| 44 | t.string "name" 45 | t.integer "folder_id" 46 | t.integer "user_id" 47 | t.datetime "created_at", null: false 48 | t.datetime "updated_at", null: false 49 | t.index ["folder_id"], name: "index_folders_on_folder_id" 50 | t.index ["name"], name: "index_folders_on_name", unique: true 51 | t.index ["user_id"], name: "index_folders_on_user_id" 52 | end 53 | 54 | create_table "people", force: :cascade do |t| 55 | t.string "name" 56 | t.integer "user_id" 57 | t.datetime "created_at", null: false 58 | t.datetime "updated_at", null: false 59 | end 60 | 61 | create_table "states", force: :cascade do |t| 62 | t.string "name" 63 | t.integer "user_id" 64 | t.datetime "created_at", null: false 65 | t.datetime "updated_at", null: false 66 | t.index ["name"], name: "index_states_on_name", unique: true 67 | end 68 | 69 | create_table "tags", force: :cascade do |t| 70 | t.string "name" 71 | t.integer "user_id" 72 | t.string "color" 73 | t.datetime "created_at", null: false 74 | t.datetime "updated_at", null: false 75 | end 76 | 77 | create_table "users", force: :cascade do |t| 78 | t.string "name" 79 | t.string "password_digest" 80 | t.string "email" 81 | t.datetime "created_at", null: false 82 | t.datetime "updated_at", null: false 83 | t.index ["email"], name: "index_users_on_email", unique: true 84 | end 85 | 86 | add_foreign_key "documents", "folders", on_delete: :nullify 87 | add_foreign_key "documents", "people", on_delete: :nullify 88 | add_foreign_key "documents", "states", on_delete: :nullify 89 | add_foreign_key "documents", "users", on_delete: :cascade 90 | add_foreign_key "documenttags", "documents" 91 | add_foreign_key "documenttags", "tags" 92 | add_foreign_key "folders", "folders" 93 | add_foreign_key "folders", "users" 94 | end 95 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) 7 | # Mayor.create(name: 'Emanuel', city: cities.first) 8 | -------------------------------------------------------------------------------- /docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '2.1' 2 | 3 | services: 4 | everydocs_core: 5 | image: jonashellmann/everydocs:latest 6 | restart: unless-stopped 7 | depends_on: 8 | everydocs_db: 9 | condition: service_healthy 10 | environment: 11 | - SECRET_KEY_BASE=${SECRET_KEY_BASE} 12 | - EVERYDOCS_DB_ADAPTER=mysql2 13 | - EVERYDOCS_DB_NAME=everydocs 14 | - EVERYDOCS_DB_USER=everydocs 15 | - EVERYDOCS_DB_PASSWORD=PASSWORD123! 16 | - EVERYDOCS_DB_HOST=everydocs_db 17 | - EVERYDOCS_DB_PORT=3306 18 | volumes: 19 | - /data/everydocs:/var/everydocs-files 20 | ports: 21 | - '5678:5678' 22 | 23 | everydocs_web: 24 | image: jonashellmann/everydocs-web:latest 25 | restart: unless-stopped 26 | volumes: 27 | - ./everydocs-web-config.js:/usr/local/apache2/htdocs/config.js 28 | ports: 29 | - '8080:80' 30 | - '8443:443' 31 | 32 | everydocs_db: 33 | image: mariadb:10.7.3 34 | restart: unless-stopped 35 | environment: 36 | - MYSQL_ROOT_PASSWORD=password 37 | - MYSQL_DATABASE=everydocs 38 | - MYSQL_USER=everydocs 39 | - MYSQL_PASSWORD=PASSWORD123! 40 | volumes: 41 | - db_data:/var/lib/mysql 42 | healthcheck: 43 | test: mysqladmin ping -h everydocs_db -u $$MYSQL_USER --password=$$MYSQL_PASSWORD 44 | start_period: 5s 45 | interval: 5s 46 | timeout: 5s 47 | retries: 10 48 | 49 | volumes: 50 | db_data: -------------------------------------------------------------------------------- /everydocs-web-config.js: -------------------------------------------------------------------------------- 1 | var config = { 2 | url: 'http://localhost:5678/', 3 | lang: 'en' 4 | } 5 | -------------------------------------------------------------------------------- /images/dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonashellmann/everydocs-core/fcff6b56ab98a57c3202ed37c10446657396de49/images/dashboard.png -------------------------------------------------------------------------------- /images/new-document.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonashellmann/everydocs-core/fcff6b56ab98a57c3202ed37c10446657396de49/images/new-document.png -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonashellmann/everydocs-core/fcff6b56ab98a57c3202ed37c10446657396de49/lib/assets/.keep -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonashellmann/everydocs-core/fcff6b56ab98a57c3202ed37c10446657396de49/lib/tasks/.keep -------------------------------------------------------------------------------- /log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonashellmann/everydocs-core/fcff6b56ab98a57c3202ed37c10446657396de49/log/.keep -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonashellmann/everydocs-core/fcff6b56ab98a57c3202ed37c10446657396de49/public/favicon.ico -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /start-app.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export RAILS_ENV=production 4 | 5 | #export SECRET_KEY_BASE="" 6 | #export EVERYDOCS_DB_ADAPTER=mysql2 7 | #export EVERYDOCS_DB_NAME=everydocs 8 | #export EVERYDOCS_DB_USER=everydocs 9 | #export EVERYDOCS_DB_PASSWORD="" 10 | #export EVERYDOCS_DB_HOST=localhost 11 | #export EVERYDOCS_DB_PORT=3306 12 | 13 | nohup rails s --port 5678 > /dev/null 2>&1 & 14 | -------------------------------------------------------------------------------- /stop-app.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pid=$(sudo lsof -t -i:5678) 4 | sudo kill -9 $pid 5 | -------------------------------------------------------------------------------- /test/controllers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonashellmann/everydocs-core/fcff6b56ab98a57c3202ed37c10446657396de49/test/controllers/.keep -------------------------------------------------------------------------------- /test/controllers/authentication_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class AuthenticationControllerTest < ActionController::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/controllers/documents_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class DocumentsControllerTest < ActionController::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/controllers/folders_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class FoldersControllerTest < ActionController::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/controllers/people_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class PeopleControllerTest < ActionController::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/controllers/search_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class SearchControllerTest < ActionDispatch::IntegrationTest 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/controllers/states_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class StatesControllerTest < ActionController::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/controllers/tags_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TagsControllerTest < ActionController::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/controllers/users_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class UsersControllerTest < ActionController::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/controllers/welcome_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class WelcomeControllerTest < ActionController::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/fixtures/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonashellmann/everydocs-core/fcff6b56ab98a57c3202ed37c10446657396de49/test/fixtures/.keep -------------------------------------------------------------------------------- /test/fixtures/documents.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | title: MyString 5 | description: MyText 6 | document_date: 2019-05-25 7 | document_url: MyString 8 | version: 9.99 9 | folder_id: 10 | user_id: 11 | state_id: 12 | 13 | two: 14 | title: MyString 15 | description: MyText 16 | document_date: 2019-05-25 17 | document_url: MyString 18 | version: 9.99 19 | folder_id: 20 | user_id: 21 | state_id: 22 | -------------------------------------------------------------------------------- /test/fixtures/documenttags.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | document_id: 5 | tag_id: 6 | 7 | two: 8 | document_id: 9 | tag_id: 10 | -------------------------------------------------------------------------------- /test/fixtures/folders.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | name: MyString 5 | folder_id: 6 | user_id: 7 | 8 | two: 9 | name: MyString 10 | folder_id: 11 | user_id: 12 | -------------------------------------------------------------------------------- /test/fixtures/people.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | name: MyString 5 | user: 6 | 7 | two: 8 | name: MyString 9 | user: 10 | -------------------------------------------------------------------------------- /test/fixtures/states.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | name: MyString 5 | 6 | two: 7 | name: MyString 8 | -------------------------------------------------------------------------------- /test/fixtures/tags.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | name: MyString 5 | user: 6 | color: MyString 7 | 8 | two: 9 | name: MyString 10 | user: 11 | color: MyString 12 | -------------------------------------------------------------------------------- /test/fixtures/users.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | name: MyString 5 | password_digest: MyString 6 | email: MyString 7 | 8 | two: 9 | name: MyString 10 | password_digest: MyString 11 | email: MyString 12 | -------------------------------------------------------------------------------- /test/helpers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonashellmann/everydocs-core/fcff6b56ab98a57c3202ed37c10446657396de49/test/helpers/.keep -------------------------------------------------------------------------------- /test/integration/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonashellmann/everydocs-core/fcff6b56ab98a57c3202ed37c10446657396de49/test/integration/.keep -------------------------------------------------------------------------------- /test/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonashellmann/everydocs-core/fcff6b56ab98a57c3202ed37c10446657396de49/test/mailers/.keep -------------------------------------------------------------------------------- /test/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonashellmann/everydocs-core/fcff6b56ab98a57c3202ed37c10446657396de49/test/models/.keep -------------------------------------------------------------------------------- /test/models/document_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class DocumentTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/models/documenttag_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class DocumenttagTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/models/folder_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class FolderTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/models/person_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class PersonTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/models/state_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class StateTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/models/tag_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TagTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/models/user_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class UserTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV['RAILS_ENV'] ||= 'test' 2 | require File.expand_path('../../config/environment', __FILE__) 3 | require 'rails/test_help' 4 | 5 | class ActiveSupport::TestCase 6 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. 7 | fixtures :all 8 | 9 | # Add more helper methods to be used by all tests here... 10 | end 11 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonashellmann/everydocs-core/fcff6b56ab98a57c3202ed37c10446657396de49/vendor/assets/javascripts/.keep -------------------------------------------------------------------------------- /vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonashellmann/everydocs-core/fcff6b56ab98a57c3202ed37c10446657396de49/vendor/assets/stylesheets/.keep --------------------------------------------------------------------------------