diff --git a/Gemfile b/Gemfile index f5e61057..536f89e4 100644 --- a/Gemfile +++ b/Gemfile @@ -22,6 +22,10 @@ gem 'html-proofer' gem 'rake' +gem 'unf_ext' + +gem 'metainspector' + # If you want to use GitHub Pages, remove the "gem "jekyll"" above and # uncomment the line below. To upgrade, run `bundle update github-pages`. # gem "github-pages", group: :jekyll_plugins diff --git a/Gemfile.lock b/Gemfile.lock index 65cd4f90..411ffa18 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,19 +1,34 @@ GEM remote: https://rubygems.org/ specs: - activesupport (5.0.2) + activesupport (5.1.0) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (~> 0.7) minitest (~> 5.1) tzinfo (~> 1.1) - addressable (2.5.0) + addressable (2.5.1) public_suffix (~> 2.0, >= 2.0.2) colorator (1.1.0) colored (1.2) concurrent-ruby (1.0.5) + domain_name (0.5.20170404) + unf (>= 0.0.5, < 1.0.0) ethon (0.10.1) ffi (>= 1.3.0) + faraday (0.12.1) + multipart-post (>= 1.2, < 3) + faraday-cookie_jar (0.0.6) + faraday (>= 0.7.4) + http-cookie (~> 1.0.0) + faraday-encoding (0.0.4) + faraday + faraday-http-cache (2.0.0) + faraday (~> 0.8) + faraday_middleware (0.11.0.1) + faraday (>= 0.7.4, < 1.0) + fastimage (2.1.0) ffi (1.9.18) + ffi (1.9.18-x86-mingw32) forwardable-extended (2.6.0) html-proofer (3.6.0) activesupport (>= 4.2, < 6.0) @@ -24,6 +39,8 @@ GEM parallel (~> 1.3) typhoeus (~> 0.7) yell (~> 2.0) + http-cookie (1.0.3) + domain_name (~> 0.5) i18n (0.8.1) jekyll (3.3.0) addressable (~> 2.4) @@ -40,7 +57,7 @@ GEM jekyll (~> 3.3) jekyll-sass-converter (1.5.0) sass (~> 3.4) - jekyll-sitemap (1.0.0) + jekyll-sitemap (1.1.1) jekyll (~> 3.3) jekyll-watch (1.5.0) listen (~> 3.0, < 3.1) @@ -50,12 +67,26 @@ GEM rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) mercenary (0.3.6) + metainspector (5.4.1) + addressable (~> 2.5) + faraday (~> 0.11) + faraday-cookie_jar (~> 0.0) + faraday-encoding (~> 0.0) + faraday-http-cache (~> 2.0) + faraday_middleware (~> 0.11) + fastimage (~> 2.1) + nesty (~> 1.0) + nokogiri (~> 1.7) mini_portile2 (2.1.0) - minima (2.1.0) + minima (2.1.1) jekyll (~> 3.3) minitest (5.10.1) + multipart-post (2.0.0) + nesty (1.0.2) nokogiri (1.7.1) mini_portile2 (~> 2.1.0) + nokogiri (1.7.1-x86-mingw32) + mini_portile2 (~> 2.1.0) parallel (1.11.1) pathutil (0.14.0) forwardable-extended (~> 2.6) @@ -72,21 +103,28 @@ GEM ethon (>= 0.8.0) tzinfo (1.2.3) thread_safe (~> 0.1) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.4) + unf_ext (0.0.7.4-x86-mingw32) yell (2.0.7) PLATFORMS ruby + x86-mingw32 DEPENDENCIES html-proofer jekyll (= 3.3.0) jekyll-feed (~> 0.6) jekyll-sitemap + metainspector minima (~> 2.0) rake + unf_ext RUBY VERSION ruby 2.2.3p173 BUNDLED WITH - 1.13.6 + 1.14.6 diff --git a/README.md b/README.md index 93397f2a..024dbb16 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,11 @@ We'd love to get contributions from you! For a quick guide to getting your syste 10. Rich data so Google can parse it. Maybe something on http://schema.org/? 11. ~~Add tweet button #47~~ +# Also check + +- [TrumpTrackerRSS](https://github.com/MrLuit/TrumpTrackerRSS) - A RSS feed of all changes in the database file +- [TrumpTrackerBot](https://github.com/MrLuit/TrumpTrackerBot) - A bot that creates a new Reddit thread for every addition to the database + # Report Issues 1. Pull Request would be the best option. 2. Otherwise you can email me @ {firstName}.{lastName}+trump@gmail.com diff --git a/Rakefile b/Rakefile index 21fa29ee..f8df1a62 100644 --- a/Rakefile +++ b/Rakefile @@ -1,67 +1,192 @@ # coding: utf-8 require 'jekyll' -# for yaml2json +# for yaml2json, generatestatic and generateurls require 'json' require 'yaml' +# for parsing source titles +#require 'openssl' +#require 'open-uri' +require 'metainspector' + # Extend string to allow for bold text. class String - def bold - "\033[1m#{self}\033[0m" - end + def bold + "\033[1m#{self}\033[0m" + end + def prettyurl + "#{self}".downcase.strip.gsub('-', '').gsub(' ', '-').gsub(/[^\w-]/, '').gsub('--', '-')[0..100] + end end # Rake Jekyll tasks task :build do - Rake::Task["json2yaml"].invoke - puts 'Building site...'.bold - Jekyll::Commands::Build.process(profile: true) + Rake::Task["generateurls"].invoke + Rake::Task["generatestatic"].invoke + Rake::Task["yaml2json"].invoke + puts 'Building site...'.bold + Jekyll::Commands::Build.process(profile: true) end task :clean do - puts 'Cleaning up _site...'.bold - Jekyll::Commands::Clean.process({}) + puts 'Cleaning up _site...'.bold + Jekyll::Commands::Clean.process({}) end task :serve do - Rake::Task["json2yaml"].invoke - puts 'Autoregenerating site...'.bold - sh "bundle exec jekyll serve" + Rake::Task["generateurls"].invoke + Rake::Task["generatestatic"].invoke + Rake::Task["yaml2json"].invoke + puts 'Autoregenerating site...'.bold + sh "bundle exec jekyll serve" end -task :json2yaml do - input_filename = "./_data/data.yaml" - output_filename = input_filename.sub(/(yml|yaml)$/, 'json') - - input_file = File.open(input_filename, 'r') - input_yml = input_file.read - input_file.close +task :generatestatic do + puts 'Generating unique promise pages...'.bold + layout_file = File.open("./_layouts/promise.html", 'r'); + layout_template = layout_file.read + yaml_file = File.open("./_data/data.yaml", 'r'); + yaml = yaml_file.read + yaml = YAML::load(yaml) + Pathname.new("./promises/").children.each { |p| p.unlink } + yaml['promises'].each_with_index { + |x, index| + title = x['title']; + status = x['status']; + comments = x['comments'] + category = x['category'] + description = x['description'] + filename = title.prettyurl + out_file = File.new("./promises/#{filename}.html", "w+") + layout = "---\nlayout: page\npermalink: /:basename/\n---\n" + layout << layout_template + $sources = '' + x['sources'].each { + |y| + #begin + # srctitle = MetaInspector.new(y, faraday_options: { ssl: { verify: false } }).title + # if srctitle == '' || srctitle.length < 5 || srctitle.length > 200 + # srctitle = y + # end + #rescue Exception => e + # puts e.message + srctitle = y + #ensure + # puts srctitle + if srctitle.include? "https://web.archive.org/web/" + srctitle = srctitle.gsub "https://web.archive.org/web/", "" + srctitle = srctitle.split("/") + srctitle.shift() + srctitle = srctitle.join("/") + end + $sources << "
  • #{srctitle}
  • \n"; + #end + } + tweettext = '@realDonaldTrump ' + if status == "Not started" + tweettext << "hasn't started" + statuscolor = '#31708f' + elsif status == "In progress" + tweettext << "is progressing" + statuscolor = '#8a6d3b' + elsif status == "Achieved" + tweettext << "achieved" + statuscolor = '#5cb85c' + elsif status == "Broken" + tweettext << "broke" + statuscolor = '#d9534f' + elsif status == "Compromised" + tweettext << "compromised on" + statuscolor = '#4e5459' + end + tweettext << " promise no. #{index}: #{title}" + tweettext_short = "#{tweettext}"[0..98] + if tweettext.length > 98 + tweettext_short << "..." + end + tweettext = CGI.escape(tweettext_short) + url = title.prettyurl + titleurl = CGI.escape(title) + layout.gsub! "