├── .gitignore ├── CNN_Article_Example.png ├── Gemfile ├── Gemfile.lock ├── README.md ├── Rakefile ├── app ├── assets │ ├── images │ │ └── .keep │ ├── javascripts │ │ ├── application.js │ │ └── articles.js.coffee │ └── stylesheets │ │ ├── _styles.css.scss │ │ ├── application.css │ │ ├── articles.css.scss │ │ ├── cnn.css │ │ ├── edit.css.scss │ │ ├── index.css.scss │ │ └── new.css.scss ├── controllers │ ├── application_controller.rb │ ├── articles_controller.rb │ └── concerns │ │ └── .keep ├── helpers │ ├── application_helper.rb │ └── articles_helper.rb ├── mailers │ └── .keep ├── models │ ├── .keep │ ├── article.rb │ └── concerns │ │ └── .keep └── views │ ├── articles │ ├── _cnn_hdr.html.erb │ ├── edit.html.erb │ ├── errorPage.html.erb │ ├── index.html.erb │ ├── new.html.erb │ └── show.html.erb │ └── layouts │ └── application.html.erb ├── bin ├── bundle ├── rails ├── rake └── 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 │ ├── filter_parameter_logging.rb │ ├── inflections.rb │ ├── mime_types.rb │ ├── session_store.rb │ └── wrap_parameters.rb ├── locales │ └── en.yml ├── routes.rb └── secrets.yml ├── db ├── migrate │ └── 20141231173256_create_articles.rb ├── schema.rb └── seeds.rb ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── log └── .keep ├── public ├── 404.html ├── 422.html ├── 500.html ├── favicon.ico └── robots.txt ├── spring └── 547f8700afc81b2d43fa0dab606aa3df.pid ├── test ├── controllers │ ├── .keep │ └── articles_controller_test.rb ├── fixtures │ ├── .keep │ └── articles.yml ├── helpers │ ├── .keep │ └── articles_helper_test.rb ├── integration │ └── .keep ├── mailers │ └── .keep ├── models │ ├── .keep │ └── article_test.rb └── test_helper.rb └── vendor └── assets ├── javascripts └── .keep └── stylesheets └── .keep /.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/*.log 16 | /tmp 17 | 18 | #Mac 19 | .DS_Store 20 | 21 | 22 | # Ignore application configuration 23 | /config/application.yml 24 | -------------------------------------------------------------------------------- /CNN_Article_Example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2016rshah/article-generator/b9d6310f00f05591938f320484d2a899f14dae73/CNN_Article_Example.png -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | 4 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 5 | gem 'rails', '4.1.6' 6 | # Use sqlite3 as the database for Active Record 7 | gem 'pg' 8 | # Use SCSS for stylesheets 9 | gem 'sass-rails', '~> 4.0.3' 10 | # Use Uglifier as compressor for JavaScript assets 11 | gem 'uglifier', '>= 1.3.0' 12 | # Use CoffeeScript for .js.coffee assets and views 13 | gem 'coffee-rails', '~> 4.0.0' 14 | # See https://github.com/sstephenson/execjs#readme for more supported runtimes 15 | # gem 'therubyracer', platforms: :ruby 16 | 17 | # Use jquery as the JavaScript library 18 | gem 'jquery-rails' 19 | 20 | gem "recaptcha", :require => "recaptcha/rails" 21 | gem 'figaro' 22 | 23 | # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks 24 | gem 'turbolinks' 25 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 26 | gem 'jbuilder', '~> 2.0' 27 | # bundle exec rake doc:rails generates the API under doc/api. 28 | gem 'sdoc', '~> 0.4.0', group: :doc 29 | 30 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 31 | gem 'spring', group: :development 32 | 33 | # Use ActiveModel has_secure_password 34 | # gem 'bcrypt', '~> 3.1.7' 35 | 36 | # Use unicorn as the app server 37 | # gem 'unicorn' 38 | 39 | # Use Capistrano for deployment 40 | # gem 'capistrano-rails', group: :development 41 | 42 | # Use debugger 43 | # gem 'debugger', group: [:development, :test] 44 | 45 | gem 'rails_12factor', group: :production 46 | 47 | ruby "2.2.1" 48 | 49 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actionmailer (4.1.6) 5 | actionpack (= 4.1.6) 6 | actionview (= 4.1.6) 7 | mail (~> 2.5, >= 2.5.4) 8 | actionpack (4.1.6) 9 | actionview (= 4.1.6) 10 | activesupport (= 4.1.6) 11 | rack (~> 1.5.2) 12 | rack-test (~> 0.6.2) 13 | actionview (4.1.6) 14 | activesupport (= 4.1.6) 15 | builder (~> 3.1) 16 | erubis (~> 2.7.0) 17 | activemodel (4.1.6) 18 | activesupport (= 4.1.6) 19 | builder (~> 3.1) 20 | activerecord (4.1.6) 21 | activemodel (= 4.1.6) 22 | activesupport (= 4.1.6) 23 | arel (~> 5.0.0) 24 | activesupport (4.1.6) 25 | i18n (~> 0.6, >= 0.6.9) 26 | json (~> 1.7, >= 1.7.7) 27 | minitest (~> 5.1) 28 | thread_safe (~> 0.1) 29 | tzinfo (~> 1.1) 30 | arel (5.0.1.20140414130214) 31 | builder (3.2.2) 32 | coffee-rails (4.0.1) 33 | coffee-script (>= 2.2.0) 34 | railties (>= 4.0.0, < 5.0) 35 | coffee-script (2.3.0) 36 | coffee-script-source 37 | execjs 38 | coffee-script-source (1.8.0) 39 | erubis (2.7.0) 40 | execjs (2.2.2) 41 | figaro (1.1.1) 42 | thor (~> 0.14) 43 | hike (1.2.3) 44 | i18n (0.7.0) 45 | jbuilder (2.2.6) 46 | activesupport (>= 3.0.0, < 5) 47 | multi_json (~> 1.2) 48 | jquery-rails (3.1.2) 49 | railties (>= 3.0, < 5.0) 50 | thor (>= 0.14, < 2.0) 51 | json (1.8.1) 52 | mail (2.6.3) 53 | mime-types (>= 1.16, < 3) 54 | mime-types (2.4.3) 55 | minitest (5.5.0) 56 | multi_json (1.10.1) 57 | pg (0.18.1) 58 | rack (1.5.2) 59 | rack-test (0.6.2) 60 | rack (>= 1.0) 61 | rails (4.1.6) 62 | actionmailer (= 4.1.6) 63 | actionpack (= 4.1.6) 64 | actionview (= 4.1.6) 65 | activemodel (= 4.1.6) 66 | activerecord (= 4.1.6) 67 | activesupport (= 4.1.6) 68 | bundler (>= 1.3.0, < 2.0) 69 | railties (= 4.1.6) 70 | sprockets-rails (~> 2.0) 71 | rails_12factor (0.0.3) 72 | rails_serve_static_assets 73 | rails_stdout_logging 74 | rails_serve_static_assets (0.0.4) 75 | rails_stdout_logging (0.0.3) 76 | railties (4.1.6) 77 | actionpack (= 4.1.6) 78 | activesupport (= 4.1.6) 79 | rake (>= 0.8.7) 80 | thor (>= 0.18.1, < 2.0) 81 | rake (10.4.2) 82 | rdoc (4.2.0) 83 | json (~> 1.4) 84 | recaptcha (0.4.0) 85 | sass (3.2.19) 86 | sass-rails (4.0.5) 87 | railties (>= 4.0.0, < 5.0) 88 | sass (~> 3.2.2) 89 | sprockets (~> 2.8, < 3.0) 90 | sprockets-rails (~> 2.0) 91 | sdoc (0.4.1) 92 | json (~> 1.7, >= 1.7.7) 93 | rdoc (~> 4.0) 94 | spring (1.2.0) 95 | sprockets (2.12.3) 96 | hike (~> 1.2) 97 | multi_json (~> 1.0) 98 | rack (~> 1.0) 99 | tilt (~> 1.1, != 1.3.0) 100 | sprockets-rails (2.2.2) 101 | actionpack (>= 3.0) 102 | activesupport (>= 3.0) 103 | sprockets (>= 2.8, < 4.0) 104 | thor (0.19.1) 105 | thread_safe (0.3.4) 106 | tilt (1.4.1) 107 | turbolinks (2.5.3) 108 | coffee-rails 109 | tzinfo (1.2.2) 110 | thread_safe (~> 0.1) 111 | uglifier (2.6.0) 112 | execjs (>= 0.3.0) 113 | json (>= 1.8.0) 114 | 115 | PLATFORMS 116 | ruby 117 | 118 | DEPENDENCIES 119 | coffee-rails (~> 4.0.0) 120 | figaro 121 | jbuilder (~> 2.0) 122 | jquery-rails 123 | pg 124 | rails (= 4.1.6) 125 | rails_12factor 126 | recaptcha 127 | sass-rails (~> 4.0.3) 128 | sdoc (~> 0.4.0) 129 | spring 130 | turbolinks 131 | uglifier (>= 1.3.0) 132 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UPDATE: 2 | 3 | This is not fake news, I actually took the entire project down. This started as an innocent way to make a beloved high school activity more enjoyable. But fake news is now like a *thing*, and I didn't want to perpetuate that trend so I stopped hosting it. I don't see a real danger of deceiving people by leaving the source code up on Github so this page will survive. 4 | 5 | # [Create Your Own CNN Article](http://cnn.rshah.org/) 6 | ![Example Article](CNN_Article_Example.png) 7 | 8 | ## How To 9 | Want to create your own CNN article? Just head over to [the site](http://cnn.rshah.org/) and click new article. You can specify the title, author, date, and content. In the content text field line-breaks will be respected. 10 | 11 | For more information see the [CNN article](http://cnn.rshah.org/articles/6) on the topic. 12 | 13 | ## Why 14 | This app originally came about to let the organizers of Model United Nations Conferences create press-releases on events (fictionally) transpiring in their committees to update the delegates. It was used extensively at TechMUN ([Thomas Jefferson High School for Science and Technology](http://www.newsweek.com/2014/09/19/number-1-high-school-america-offers-real-head-start-268693.html)'s MUN conference) in the Russian Cabinet Committee and the United Nations Security Council Committee. 15 | 16 | Nowadays though it is just for anybody who wants to spoof a CNN article. Want to tweet an outrageous headline? Do it. Want to trick your friends? Go for it. Want to see your name in an international headline? Follow your dreams. 17 | 18 | ## To Do 19 | - User Accounts 20 | - Make it more secure (there are massive security flaws right now) 21 | - ~~Images in articles~~ 22 | - ~~Links in articles~~ 23 | - ~~Editing articles after they are created~~ 24 | - Allow more customization of articles like the credit paragraph and the sidebar content 25 | - Style the list of articles to look like they are on CNN as well 26 | - Input validation (no empty fields, etc.) 27 | 28 | ## Contributing 29 | Think this project is awesome? Contribute to it! Think it is really awful? Contribute to it anyways to make it less awful! Either way, please contribute! If you see anything you want to help out with open up an issue. If you think your fix is simple enough not to warrant an issue just send in a pull request. As usual, follow good coding practice: please keep code neat, make sure it works, etc. 30 | 31 | ## Deploying to Heroku 32 | 33 | Whip up your own heroku app and google recaptcha instance, then 34 | 35 | ``` 36 | $ heroku git:remote -a name-of-your-heroku-app 37 | $ heroku run rake db:migrate 38 | $ heroku config:set RECAPTCHA_PRIVATE_KEY= 39 | $ heroku config:set RECAPTCHA_PUBLIC_KEY= 40 | ``` 41 | 42 | ## How it's made 43 | This is a Ruby on Rails application (my first, in fact!) that was deployed using Heroku. 44 | -------------------------------------------------------------------------------- /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/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2016rshah/article-generator/b9d6310f00f05591938f320484d2a899f14dae73/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 vendor/assets/javascripts of plugins, if any, 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/sstephenson/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/articles.js.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/_styles.css.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * btns.css 4 | * Simple css utilities for building responsive buttons 5 | * Author: mrmrs 6 | * License: MIT 7 | * 8 | * */ 9 | 10 | /* 11 | 12 | Base .btn class 13 | 14 | Code: 15 | Default button 16 | 17 | */ 18 | 19 | .btn, 20 | .btn:link, 21 | .btn:visited { 22 | border-radius: .3em; 23 | border-style: solid; 24 | border-width: 1px; 25 | color: #111; 26 | display: inline-block; 27 | font-family: avenir, helvetica, arial, sans-serif; 28 | letter-spacing: .15em; 29 | margin-bottom: .5em; 30 | padding: 1em .75em; 31 | text-decoration: none; 32 | text-transform: uppercase; 33 | transition: color .4s, background-color .4s, border .4s; 34 | } 35 | 36 | .btn:hover, 37 | .btn:focus { 38 | color: #7FDBFF; 39 | border: 1px solid #7FDBFF; 40 | transition: background-color .3s, color .3s, border .3s; 41 | } 42 | 43 | .btn:active { 44 | color: #0074D9; 45 | border: 1px solid #0074D9; 46 | transition: background-color .3s, color .3s, border .3s; 47 | } 48 | 49 | 50 | /* 51 | 52 | Sizes 53 | 54 | Small = .btn--s 55 | Medium = .btn--m 56 | Large = .btn--l 57 | 58 | Code: 59 | 60 | 61 | 62 | 63 | */ 64 | 65 | .btn--s { font-size: 12px; } 66 | .btn--m { font-size: 14px; } 67 | .btn--l { font-size: 20px; border-radius: .25em!important; } 68 | 69 | 70 | /* 71 | 72 | Layout utility for responsive buttons 73 | 74 | Code: 75 | 76 | 77 | */ 78 | 79 | .btn--full, 80 | .btn--full:link { 81 | border-radius: .25em; 82 | display: block; 83 | margin-left: auto; 84 | margin-right: auto; 85 | text-align: center; 86 | width: 100%; 87 | } 88 | 89 | 90 | /* 91 | 92 | Skins 93 | 94 | * Black & White 95 | * Grays 96 | * Colors 97 | 98 | Code: 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | */ 107 | 108 | /* BLACK & WHITE */ 109 | 110 | .btn--black, 111 | .btn--black:link, 112 | .btn--black:visited { 113 | color: #fff; 114 | background-color: #000; 115 | } 116 | 117 | .btn--black:hover, 118 | .btn--black:focus { 119 | color: #fff; 120 | background-color: #777; 121 | border-color: #777; 122 | } 123 | 124 | .btn--black:active { 125 | color: #fff; 126 | background-color: #999; 127 | border-color: #999; 128 | } 129 | 130 | .btn--black:hover, 131 | .btn--black:focus { 132 | background-color: #444; 133 | } 134 | 135 | .btn--black { 136 | background-color: #000; 137 | } 138 | 139 | .btn--gray:link, 140 | .btn--gray:visited, { 141 | background-color: #f0f0f0; 142 | border-color: #f0f0f0; 143 | color: #555; 144 | } 145 | 146 | .btn--gray:hover, 147 | .btn--gray:focus { 148 | background-color: #ddd; 149 | border-color: #ddd; 150 | color: #444; 151 | } 152 | 153 | .btn--gray:active { 154 | background-color: #ccc; 155 | border-color: #ccc; 156 | color: #444; 157 | } 158 | 159 | .btn--gray-border:link, 160 | .btn--gray-border:visited, { 161 | background-color: #fff; 162 | border-color: #555; 163 | border-width: 2px; 164 | color: #555; 165 | } 166 | 167 | .btn--gray-border:hover, 168 | .btn--gray-border:focus { 169 | background-color: #fff; 170 | border-color: #ddd; 171 | color: #777; 172 | } 173 | 174 | .btn--gray-border:active { 175 | background-color: #ccc; 176 | border-color: #ccc; 177 | color: #444; 178 | } 179 | 180 | .btn--gray-dark:link, 181 | .btn--gray-dark:visited { 182 | background-color: #555; 183 | color: #eee; 184 | } 185 | 186 | .btn--gray-dark:hover, 187 | .btn--gray-dark:focus { 188 | background-color: #333; 189 | border-color: #333; 190 | color: #eee; 191 | } 192 | 193 | .btn--gray-dark:active { 194 | background-color: #777; 195 | border-color: #777; 196 | color: #eee; 197 | } 198 | 199 | 200 | /* BLUES */ 201 | 202 | .btn--blue:link, 203 | .btn--blue:visited { 204 | color: #fff; 205 | background-color: #0074D9; 206 | } 207 | 208 | .btn--blue:hover, 209 | .btn--blue:focus { 210 | color: #fff!important; 211 | background-color: #0063aa; 212 | border-color: #0063aa; 213 | } 214 | 215 | .btn--blue:active { 216 | color: #fff; 217 | background-color: #001F3F; 218 | border-color: #001F3F; 219 | } 220 | 221 | /* Keep it mobile-first and responsive */ 222 | 223 | @media screen and (min-width: 32em) { 224 | .btn--full { 225 | max-width: 16em!important; 226 | } 227 | } -------------------------------------------------------------------------------- /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 vendor/assets/stylesheets of plugins, if any, 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 | 17 | .cnn_storyarea { 18 | margin-right:auto; 19 | margin-left:auto; 20 | } 21 | .cnn_storyarea p { 22 | width : 100%; 23 | } -------------------------------------------------------------------------------- /app/assets/stylesheets/articles.css.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the articles controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ -------------------------------------------------------------------------------- /app/assets/stylesheets/edit.css.scss: -------------------------------------------------------------------------------- 1 | .edit{ 2 | @import "styles"; 3 | text-align:center; 4 | .form{ 5 | float:left; 6 | height:86%; 7 | width:100%; 8 | box-sizing:border-box; 9 | padding:40px; 10 | } 11 | .textbox{ 12 | height:50px; 13 | width:20%; 14 | border-radius:3px; 15 | border:rgba(0,0,0,.3) 2px solid; 16 | box-sizing:border-box; 17 | padding:10px; 18 | margin-bottom:30px; 19 | } 20 | 21 | .textbox:focus{ 22 | outline:none; 23 | border:rgba(24,149,215,1) 2px solid; 24 | color:rgba(24,149,215,1); 25 | } 26 | 27 | .textarea{ 28 | height:300px; 29 | width:60%; 30 | } 31 | 32 | .title{ 33 | width:60%; 34 | } 35 | .info{ 36 | width:30%; 37 | } 38 | h1{ 39 | font-size:50px; 40 | } 41 | } -------------------------------------------------------------------------------- /app/assets/stylesheets/index.css.scss: -------------------------------------------------------------------------------- 1 | .index { 2 | @import "styles"; 3 | text-align:center; 4 | 5 | h1 { 6 | font-size:40px; 7 | } 8 | a { 9 | font-size:30px; 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /app/assets/stylesheets/new.css.scss: -------------------------------------------------------------------------------- 1 | .new { 2 | @import "styles"; 3 | text-align:center; 4 | .form{ 5 | float:left; 6 | height:86%; 7 | width:100%; 8 | box-sizing:border-box; 9 | padding:40px; 10 | } 11 | .textbox{ 12 | height:50px; 13 | width:20%; 14 | border-radius:3px; 15 | border:rgba(0,0,0,.3) 2px solid; 16 | box-sizing:border-box; 17 | padding:10px; 18 | margin-bottom:30px; 19 | } 20 | 21 | .textbox:focus{ 22 | outline:none; 23 | border:rgba(24,149,215,1) 2px solid; 24 | color:rgba(24,149,215,1); 25 | } 26 | 27 | .textarea{ 28 | height:300px; 29 | width:60%; 30 | } 31 | 32 | .title{ 33 | width:60%; 34 | } 35 | .info{ 36 | width:30%; 37 | } 38 | h1{ 39 | font-size:50px; 40 | } 41 | 42 | .g-recaptcha{ 43 | width:304px; 44 | margin-right:auto; 45 | margin-left:auto; 46 | margin-bottom:10px; 47 | } 48 | } -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks by raising an exception. 3 | # For APIs, you may want to use :null_session instead. 4 | protect_from_forgery with: :exception 5 | end 6 | -------------------------------------------------------------------------------- /app/controllers/articles_controller.rb: -------------------------------------------------------------------------------- 1 | class ArticlesController < ApplicationController 2 | before_action :find_article, only: [:show, :edit, :update, :destroy] 3 | def index 4 | @articles = Article.all.order("created_at DESC") 5 | end 6 | 7 | def create 8 | if verify_recaptcha(:model => @post, :message => "Oh! It's error with reCAPTCHA!", :private_key => ENV["RECAPTCHA_PRIVATE_KEY"]) 9 | @article = Article.new(article_params) 10 | if @article.save 11 | redirect_to @article 12 | else 13 | redirect_to :action => 'errorPage' 14 | end 15 | else 16 | redirect_to :action => 'errorPage' 17 | end 18 | end 19 | 20 | def errorPage 21 | end 22 | 23 | def show 24 | #@article is defined in the before_action 25 | end 26 | 27 | def destroy 28 | @article.destroy 29 | redirect_to root_path 30 | end 31 | 32 | def edit 33 | 34 | end 35 | 36 | def update 37 | if @article.update_attributes(params[:article].permit(:title, :author, :date, :content)) 38 | redirect_to :action => 'show', :id => @article 39 | else 40 | render :action => 'edit', :id => @article 41 | end 42 | end 43 | 44 | private 45 | 46 | def article_params 47 | params.require(:article).permit(:title, :author, :date, :content) 48 | end 49 | 50 | def find_article 51 | @article = Article.find(params[:id]) 52 | end 53 | 54 | end 55 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2016rshah/article-generator/b9d6310f00f05591938f320484d2a899f14dae73/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/articles_helper.rb: -------------------------------------------------------------------------------- 1 | module ArticlesHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2016rshah/article-generator/b9d6310f00f05591938f320484d2a899f14dae73/app/mailers/.keep -------------------------------------------------------------------------------- /app/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2016rshah/article-generator/b9d6310f00f05591938f320484d2a899f14dae73/app/models/.keep -------------------------------------------------------------------------------- /app/models/article.rb: -------------------------------------------------------------------------------- 1 | class Article < ActiveRecord::Base 2 | validates :title, uniqueness: true 3 | end 4 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2016rshah/article-generator/b9d6310f00f05591938f320484d2a899f14dae73/app/models/concerns/.keep -------------------------------------------------------------------------------- /app/views/articles/_cnn_hdr.html.erb: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 |
5 |
6 | 7 | CNN World 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 | 26 |
27 |
28 | 41 |
42 |
43 | 44 | 78 |
79 |
80 |
81 | 121 |
122 |
-------------------------------------------------------------------------------- /app/views/articles/edit.html.erb: -------------------------------------------------------------------------------- 1 | <% content_for :title, "Edit Article" %> 2 |
3 |

Edit Article

4 |
5 | <%= form_for @article do |f| %> 6 | <%= f.text_field :title, class: "textbox title", placeholder: :Title %>
7 | <%= f.text_field :author, class: "textbox info", placeholder: :Author %> 8 | <%= f.text_field :date, class: "textbox info", placeholder: :Date %> 9 | <%= f.text_area :content, class: "textbox textarea", placeholder: :Content %> 10 |
11 | <%= f.submit "Submit", class: "btn btn--blue" %> 12 | <% end %> 13 | <%= link_to "Home", root_path, class: "btn btn--gray-border" %> 14 |
15 |
-------------------------------------------------------------------------------- /app/views/articles/errorPage.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Oops, something went wrong

3 |

Maybe you tried to save an article that's already been created?

4 | <%= link_to "Go home.", root_path, class: "btn btn--m btn--blue" %> 5 |
-------------------------------------------------------------------------------- /app/views/articles/index.html.erb: -------------------------------------------------------------------------------- 1 | <% content_for :title, "Article Generator" %> 2 |
3 |

CNN Article Generator

4 | <%= link_to "New article", new_article_path, class: "btn btn--m btn--blue" %> 5 |

All articles

6 | <% @articles.each do |article| %> 7 | <%= link_to article.title+" by "+article.author, article %> 8 |
9 | <% end %> 10 |
-------------------------------------------------------------------------------- /app/views/articles/new.html.erb: -------------------------------------------------------------------------------- 1 | <% content_for :title, "New Article" %> 2 |
3 |

New Article

4 |
5 | <%= form_for :article, url: articles_path do |f| %> 6 | <%= f.text_field :title, class: "textbox title", placeholder: :Title %>
7 | <%= f.text_field :author, class: "textbox info", placeholder: :Author %> 8 | <%= f.text_field :date, class: "textbox info", placeholder: :Date %> 9 | <%= f.text_area :content, class: "textbox textarea", placeholder: :Content %> 10 |
11 | <%= recaptcha_tags :public_key => ENV["RECAPTCHA_PUBLIC_KEY"] %> 12 | <%= f.submit "Submit", class: "btn btn--blue" %> 13 | <% end %> 14 | <%= link_to "Home", root_path, class: "btn btn--gray-border" %> 15 |
16 |
-------------------------------------------------------------------------------- /app/views/articles/show.html.erb: -------------------------------------------------------------------------------- 1 | <% content_for :title, @article.title %> 2 | <%= render 'cnn_hdr' %> 3 |
4 |

<%= @article.title %>

5 |
6 |
By <%= @article.author %>, CNN
7 |
Updated <%= @article.date %>
8 |
9 |
10 |
11 |
12 |
SITE HIGHLIGHTS
13 |
    14 |
  • NEW: New articles can be made at the new page
  • 15 |
  • NEW: All past articles can be viewed on the index page
  • 16 |
  • View the source on github
  • 17 |
  • 'Twas made with Ruby on Rails by Rushi Shah
  • 18 |
  • This is in no way affiliated with the actual CNN.com.
  • 19 |
20 |
21 |
22 |

<%= simple_format (sanitize @article.content, tags: %w(b strong i em a img)) %>

23 |

This is just an example of a credit paragraph. CNN's Rushi Shah and <%= @article.author %> were involved in the making of this article.

24 |
25 |
-------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= yield(:title) %> 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 | 12 | <%= yield %> 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /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/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | APP_PATH = File.expand_path('../../config/application', __FILE__) 7 | require_relative '../config/boot' 8 | require 'rails/commands' 9 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | require_relative '../config/boot' 7 | require 'rake' 8 | Rake.application.run 9 | -------------------------------------------------------------------------------- /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 | if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m) 11 | ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR) 12 | ENV["GEM_HOME"] = "" 13 | Gem.paths = ENV 14 | 15 | gem "spring", match[1] 16 | require "spring/binstub" 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /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 ArticleGenerator 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 | end 23 | end 24 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | # Set up gems listed in the Gemfile. 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | 4 | require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) 5 | -------------------------------------------------------------------------------- /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 | # <<: *default 25 | # database: db/production.sqlite3 26 | 27 | 28 | # PostgreSQL. Versions 8.2 and up are supported. 29 | # 30 | # Install the pg driver: 31 | # gem install pg 32 | # On OS X with Homebrew: 33 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config 34 | # On OS X with MacPorts: 35 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config 36 | # On Windows: 37 | # gem install pg 38 | # Choose the win32 build. 39 | # Install PostgreSQL and put its /bin directory on your path. 40 | # 41 | # Configure Using Gemfile 42 | # gem 'pg' 43 | # 44 | default: &default 45 | adapter: postgresql 46 | encoding: unicode 47 | # For details on connection pooling, see rails configuration guide 48 | # http://guides.rubyonrails.org/configuring.html#database-pooling 49 | pool: 5 50 | 51 | development: 52 | <<: *default 53 | database: article_generator_development 54 | 55 | # The specified database role being used to connect to postgres. 56 | # To create additional roles in postgres see `$ createuser --help`. 57 | # When left blank, postgres will use the default role. This is 58 | # the same name as the operating system user that initialized the database. 59 | #username: myapp 60 | 61 | # The password associated with the postgres role (username). 62 | #password: 63 | 64 | # Connect on a TCP socket. Omitted by default since the client uses a 65 | # domain socket that doesn't need configuration. Windows does not have 66 | # domain sockets, so uncomment these lines. 67 | #host: localhost 68 | 69 | # The TCP port the server listens on. Defaults to 5432. 70 | # If your server runs on a different port number, change accordingly. 71 | #port: 5432 72 | 73 | # Schema search path. The server defaults to $user,public 74 | #schema_search_path: myapp,sharedapp,public 75 | 76 | # Minimum log levels, in increasing order: 77 | # debug5, debug4, debug3, debug2, debug1, 78 | # log, notice, warning, error, fatal, and panic 79 | # Defaults to warning. 80 | #min_messages: notice 81 | 82 | # Warning: The database defined as "test" will be erased and 83 | # re-generated from your development database when you run "rake". 84 | # Do not set this db to the same as development or production. 85 | test: 86 | <<: *default 87 | database: article_generator_test 88 | 89 | # As with config/secrets.yml, you never want to store sensitive information, 90 | # like your database password, in your source code. If your source code is 91 | # ever seen by anyone, they now have access to your database. 92 | # 93 | # Instead, provide the password as a unix environment variable when you boot 94 | # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database 95 | # for a full rundown on how to provide these environment variables in a 96 | # production deployment. 97 | # 98 | # On Heroku and other platform providers, you may have a full connection URL 99 | # available as an environment variable. For example: 100 | # 101 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" 102 | # 103 | # You can use this database configuration with: 104 | # 105 | # production: 106 | # url: <%= ENV['DATABASE_URL'] %> 107 | # 108 | production: 109 | <<: *default 110 | database: article_generator_production 111 | username: myapp 112 | password: <%= ENV['MYAPP_DATABASE_PASSWORD'] %> 113 | -------------------------------------------------------------------------------- /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 | # Adds additional error checking when serving assets at runtime. 31 | # Checks for improperly declared sprockets dependencies. 32 | # Raises helpful error messages. 33 | config.assets.raise_runtime_errors = true 34 | 35 | # Raises error for missing translations 36 | # config.action_view.raise_on_missing_translations = true 37 | end 38 | -------------------------------------------------------------------------------- /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 nginx, varnish or squid. 20 | # config.action_dispatch.rack_cache = true 21 | 22 | # Disable Rails's static asset server (Apache or nginx will already do this). 23 | config.serve_static_assets = false 24 | 25 | # Compress JavaScripts and CSS. 26 | config.assets.js_compressor = :uglifier 27 | # config.assets.css_compressor = :sass 28 | 29 | # Do not fallback to assets pipeline if a precompiled asset is missed. 30 | config.assets.compile = false 31 | 32 | # Generate digests for assets URLs. 33 | config.assets.digest = true 34 | 35 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 36 | 37 | # Specifies the header that your server uses for sending files. 38 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache 39 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 40 | 41 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 42 | # config.force_ssl = true 43 | 44 | # Set to :debug to see everything in the log. 45 | config.log_level = :info 46 | 47 | # Prepend all log lines with the following tags. 48 | # config.log_tags = [ :subdomain, :uuid ] 49 | 50 | # Use a different logger for distributed setups. 51 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 52 | 53 | # Use a different cache store in production. 54 | # config.cache_store = :mem_cache_store 55 | 56 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 57 | # config.action_controller.asset_host = "http://assets.example.com" 58 | 59 | # Ignore bad email addresses and do not raise email delivery errors. 60 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 61 | # config.action_mailer.raise_delivery_errors = false 62 | 63 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 64 | # the I18n.default_locale when a translation cannot be found). 65 | config.i18n.fallbacks = true 66 | 67 | # Send deprecation notices to registered listeners. 68 | config.active_support.deprecation = :notify 69 | 70 | # Disable automatic flushing of the log to improve performance. 71 | # config.autoflush_log = false 72 | 73 | # Use default logging formatter so that PID and timestamp are not suppressed. 74 | config.log_formatter = ::Logger::Formatter.new 75 | 76 | # Do not dump schema after migrations. 77 | config.active_record.dump_schema_after_migration = false 78 | end 79 | -------------------------------------------------------------------------------- /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 = true 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 asset server for tests with Cache-Control for performance. 16 | config.serve_static_assets = 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 | # Print deprecation notices to the stderr. 35 | config.active_support.deprecation = :stderr 36 | 37 | # Raises error for missing translations 38 | # config.action_view.raise_on_missing_translations = true 39 | end 40 | -------------------------------------------------------------------------------- /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 | # Precompile additional assets. 7 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 8 | # Rails.application.config.assets.precompile += %w( search.js ) 9 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /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: '_article_generator_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 | resources :articles 3 | get '/articles/:id/destroy', to: 'articles#destroy' 4 | get '/errorPage', to: 'articles#errorPage' 5 | root "articles#index" 6 | end 7 | -------------------------------------------------------------------------------- /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: 3a60b8e89ee2b6880c8be4a8c806e8d36e7fb70c68a42309a4b4c46505a19af424941d9b6a65dae3f087868184f074124afc4fbb6c9411bbf12a0ce12d57c6cc 15 | 16 | test: 17 | secret_key_base: fba42655cb5bb3ea99225b1eb8d8d59bdca4a888b1023ebbd155a25975dfcb3563710b09cbea84d55977ce3a8eaef554ed47cfd0c05da6d5938bd5fca6334050 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 | -------------------------------------------------------------------------------- /db/migrate/20141231173256_create_articles.rb: -------------------------------------------------------------------------------- 1 | class CreateArticles < ActiveRecord::Migration 2 | def change 3 | create_table :articles do |t| 4 | t.string :title 5 | t.string :author 6 | t.string :date 7 | t.text :content 8 | 9 | t.timestamps 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # This file is auto-generated from the current state of the database. Instead 3 | # of editing this file, please use the migrations feature of Active Record to 4 | # incrementally modify your database, and then regenerate this schema definition. 5 | # 6 | # Note that this schema.rb definition is the authoritative source for your 7 | # database schema. If you need to create the application database on another 8 | # system, you should be using db:schema:load, not running all the migrations 9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 10 | # you'll amass, the slower it'll run and the greater likelihood for issues). 11 | # 12 | # It's strongly recommended that you check this file into your version control system. 13 | 14 | ActiveRecord::Schema.define(version: 20141231173256) do 15 | 16 | # These are extensions that must be enabled in order to support this database 17 | enable_extension "plpgsql" 18 | 19 | create_table "articles", force: true do |t| 20 | t.string "title" 21 | t.string "author" 22 | t.string "date" 23 | t.text "content" 24 | t.datetime "created_at" 25 | t.datetime "updated_at" 26 | end 27 | 28 | end 29 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2016rshah/article-generator/b9d6310f00f05591938f320484d2a899f14dae73/lib/assets/.keep -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2016rshah/article-generator/b9d6310f00f05591938f320484d2a899f14dae73/lib/tasks/.keep -------------------------------------------------------------------------------- /log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2016rshah/article-generator/b9d6310f00f05591938f320484d2a899f14dae73/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/2016rshah/article-generator/b9d6310f00f05591938f320484d2a899f14dae73/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 | -------------------------------------------------------------------------------- /spring/547f8700afc81b2d43fa0dab606aa3df.pid: -------------------------------------------------------------------------------- 1 | 725 2 | -------------------------------------------------------------------------------- /test/controllers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2016rshah/article-generator/b9d6310f00f05591938f320484d2a899f14dae73/test/controllers/.keep -------------------------------------------------------------------------------- /test/controllers/articles_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ArticlesControllerTest < ActionController::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/fixtures/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2016rshah/article-generator/b9d6310f00f05591938f320484d2a899f14dae73/test/fixtures/.keep -------------------------------------------------------------------------------- /test/fixtures/articles.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | title: MyString 5 | author: MyString 6 | date: MyString 7 | content: MyText 8 | 9 | two: 10 | title: MyString 11 | author: MyString 12 | date: MyString 13 | content: MyText 14 | -------------------------------------------------------------------------------- /test/helpers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2016rshah/article-generator/b9d6310f00f05591938f320484d2a899f14dae73/test/helpers/.keep -------------------------------------------------------------------------------- /test/helpers/articles_helper_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ArticlesHelperTest < ActionView::TestCase 4 | end 5 | -------------------------------------------------------------------------------- /test/integration/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2016rshah/article-generator/b9d6310f00f05591938f320484d2a899f14dae73/test/integration/.keep -------------------------------------------------------------------------------- /test/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2016rshah/article-generator/b9d6310f00f05591938f320484d2a899f14dae73/test/mailers/.keep -------------------------------------------------------------------------------- /test/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2016rshah/article-generator/b9d6310f00f05591938f320484d2a899f14dae73/test/models/.keep -------------------------------------------------------------------------------- /test/models/article_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ArticleTest < 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/2016rshah/article-generator/b9d6310f00f05591938f320484d2a899f14dae73/vendor/assets/javascripts/.keep -------------------------------------------------------------------------------- /vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2016rshah/article-generator/b9d6310f00f05591938f320484d2a899f14dae73/vendor/assets/stylesheets/.keep --------------------------------------------------------------------------------