commit b0430e51ff91b8962f19ffa673998a7b980a143f Author: Nemo Date: Tue Jun 6 14:43:12 2023 +0530 Initial Commit diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..6335ee3 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,54 @@ +# Based on https://github.com/actions/starter-workflows/blob/main/pages/jekyll.yml +name: publish +on: + push: + branches: + - main + schedule: + # 9th minute of every hour + - cron: '09 * * * *' + permissions: + contents: read + pages: write + id-token: write + # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. + # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. + concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Build job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Ruby + uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 + with: + ruby-version: '3.0' # Not needed with a .ruby-version file + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - name: Setup Pages + id: pages + uses: actions/configure-pages@v3 + - name: Build with Jekyll + # Outputs to the './_site' directory by default + run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}" + env: + JEKYLL_ENV: production + - name: Upload artifact + # Automatically uploads an artifact from the './_site' directory by default + uses: actions/upload-pages-artifact@v1 + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5657f6e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +vendor \ No newline at end of file diff --git a/404.html b/404.html new file mode 100644 index 0000000..086a5c9 --- /dev/null +++ b/404.html @@ -0,0 +1,25 @@ +--- +permalink: /404.html +layout: default +--- + + + +
+

404

+ +

Page not found :(

+

The requested page could not be found.

+
diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..e4b1486 --- /dev/null +++ b/Gemfile @@ -0,0 +1,35 @@ +source "https://rubygems.org" +# Hello! This is where you manage which Jekyll version is used to run. +# When you want to use a different version, change it below, save the +# file and run `bundle install`. Run Jekyll with `bundle exec`, like so: +# +# bundle exec jekyll serve +# +# This will help ensure the proper Jekyll version is running. +# Happy Jekylling! +gem "jekyll", "~> 4.3.2" +# This is the default theme for new Jekyll sites. You may change this to anything you like. +gem "minima", "~> 2.5" +# 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 +# If you have any plugins, put them here! +group :jekyll_plugins do + gem "jekyll-feed", "~> 0.12" +end + +# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem +# and associated library. +platforms :mingw, :x64_mingw, :mswin, :jruby do + gem "tzinfo", ">= 1", "< 3" + gem "tzinfo-data" +end + +# Performance-booster for watching directories on Windows +gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin] + +# Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem +# do not have a Java counterpart. +gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby] + +gem "sanitize", "~> 6.0" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..76d586c --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,92 @@ +GEM + remote: https://rubygems.org/ + specs: + addressable (2.8.4) + public_suffix (>= 2.0.2, < 6.0) + colorator (1.1.0) + concurrent-ruby (1.2.2) + crass (1.0.6) + em-websocket (0.5.3) + eventmachine (>= 0.12.9) + http_parser.rb (~> 0) + eventmachine (1.2.7) + ffi (1.15.5) + forwardable-extended (2.6.0) + google-protobuf (3.23.2-x86_64-linux) + http_parser.rb (0.8.0) + i18n (1.14.1) + concurrent-ruby (~> 1.0) + jekyll (4.3.2) + addressable (~> 2.4) + colorator (~> 1.0) + em-websocket (~> 0.5) + i18n (~> 1.0) + jekyll-sass-converter (>= 2.0, < 4.0) + jekyll-watch (~> 2.0) + kramdown (~> 2.3, >= 2.3.1) + kramdown-parser-gfm (~> 1.0) + liquid (~> 4.0) + mercenary (>= 0.3.6, < 0.5) + pathutil (~> 0.9) + rouge (>= 3.0, < 5.0) + safe_yaml (~> 1.0) + terminal-table (>= 1.8, < 4.0) + webrick (~> 1.7) + jekyll-feed (0.17.0) + jekyll (>= 3.7, < 5.0) + jekyll-sass-converter (3.0.0) + sass-embedded (~> 1.54) + jekyll-seo-tag (2.8.0) + jekyll (>= 3.8, < 5.0) + jekyll-watch (2.2.1) + listen (~> 3.0) + kramdown (2.4.0) + rexml + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) + liquid (4.0.4) + listen (3.8.0) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + mercenary (0.4.0) + minima (2.5.1) + jekyll (>= 3.5, < 5.0) + jekyll-feed (~> 0.9) + jekyll-seo-tag (~> 2.1) + nokogiri (1.15.2-x86_64-linux) + racc (~> 1.4) + pathutil (0.16.2) + forwardable-extended (~> 2.6) + public_suffix (5.0.1) + racc (1.6.2) + rb-fsevent (0.11.2) + rb-inotify (0.10.1) + ffi (~> 1.0) + rexml (3.2.5) + rouge (4.1.2) + safe_yaml (1.0.5) + sanitize (6.0.1) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + sass-embedded (1.62.1-x86_64-linux-gnu) + google-protobuf (~> 3.21) + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) + unicode-display_width (2.4.2) + webrick (1.8.1) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + http_parser.rb (~> 0.6.0) + jekyll (~> 4.3.2) + jekyll-feed (~> 0.12) + minima (~> 2.5) + sanitize (~> 6.0) + tzinfo (>= 1, < 3) + tzinfo-data + wdm (~> 0.1.1) + +BUNDLED WITH + 2.4.12 diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..7b7759c --- /dev/null +++ b/_config.yml @@ -0,0 +1,27 @@ +title: "Beatroot News: Text-only" +description: >- # this means to ignore newlines until "baseurl:" + A plain-text version of Beatroot News. +baseurl: "" +url: "https://news.captnemo.in" +plugins: + - jekyll-feed + +# Exclude from processing. +# The following items will not be processed, by default. +# Any item listed under the `exclude:` key here will be automatically added to +# the internal "default list". +# +# Excluded items can be processed by explicitly listing the directories or +# their entries' file path in the `include:` list. +# +# exclude: +# - .sass-cache/ +# - .jekyll-cache/ +# - gemfiles/ +# - Gemfile +# - Gemfile.lock +# - node_modules/ +# - vendor/bundle/ +# - vendor/cache/ +# - vendor/gems/ +# - vendor/ruby/ \ No newline at end of file diff --git a/_includes/header.html b/_includes/header.html new file mode 100644 index 0000000..84c47c5 --- /dev/null +++ b/_includes/header.html @@ -0,0 +1,101 @@ + + + + diff --git a/_layouts/article.html b/_layouts/article.html new file mode 100644 index 0000000..39610d5 --- /dev/null +++ b/_layouts/article.html @@ -0,0 +1,21 @@ +--- +layout: default +--- +
+
+

+ Beatroot > + {{page.topics.first | capitalize}} +

+
+

{{page.title}}

+

{{page.sources | join: " "}}

+

{{page.date | date: "%A, %b, %e, %Y"}}

+
+
+ +
+ {{content}} +
+
+
\ No newline at end of file diff --git a/_layouts/default.html b/_layouts/default.html new file mode 100644 index 0000000..95f0fc0 --- /dev/null +++ b/_layouts/default.html @@ -0,0 +1,44 @@ + + + + {{page.title}} + {% include header.html %} + + +
+

Text-Only + iOS + Android + Mobile Web +

+
+ +
+ {{content}} +
+ + +
+ + + + + + + diff --git a/_layouts/topic.html b/_layouts/topic.html new file mode 100644 index 0000000..fb48f8d --- /dev/null +++ b/_layouts/topic.html @@ -0,0 +1,24 @@ +--- +layout: default +--- +

+ Beatroot > {{page.title | capitalize}} +

+
+

{{page.title | capitalize}}

+
+

{{site.time | date: "%A, %b, %e, %Y"}}

+ +
diff --git a/_plugins/fetch_posts.rb b/_plugins/fetch_posts.rb new file mode 100644 index 0000000..1f45e8b --- /dev/null +++ b/_plugins/fetch_posts.rb @@ -0,0 +1,92 @@ +# frozen_string_literal: true +require 'sanitize' +require 'uri' +require 'net/http' +require 'set' +require 'date' + +class PageWithoutAFile < Jekyll::Page + def read_yaml(*) + @data ||= {} + end +end + +class BeatrootNews < Jekyll::Generator + safe true + priority :high + + SOURCE_URL = "https://beatrootnews.com/api.php/article?page%5Blimit%5D=60&sort=-publishing_date" + + # Make a request to SOURCE_URL, and return the parsed JSON + def get_content + uri = URI.parse(SOURCE_URL) + response = Net::HTTP.get_response(uri) + JSON.parse(response.body)['data'] + end + + # Main plugin action, called by Jekyll-core + def generate(site) + @site = site + topics = Set.new + get_content.each do |article| + page = make_page(article['attributes']['modules']) + if page + site.pages << page + page['topics'].each { |t| topics.add(t) } + end + end + + topics.each do |topic| + @site.pages << make_topic_page(topic) + end + site.config['topics'] = topics.to_a + end + + private + + def make_topic_page(topic) + PageWithoutAFile.new(@site, __dir__, topic, "index.html").tap do |file| + file.data.merge!( + 'title' => topic.capitalize, + 'layout' => 'topic', + 'topic' => topic, + 'permalink' => "/#{topic}/", + ) + file.output + end + end + + # Generates contents for a file + + def timestamp(ts) + d = Time.at(ts.to_i).to_datetime + d.new_offset("+0530") + end + + def make_page(article) + return nil if article['topic'].nil? + n = DateTime.new + now = DateTime.new(n.year, n.month, n.day, 23, 59, 59, "+0530") + PageWithoutAFile.new(@site, __dir__, article['id'], "index.html").tap do |file| + html = article['body_json']['blocks'].map{ |t| t['data']['text']}.join(" ") + topics = article['topic'].map { |topic| topic.split('-').first } + if article['trigger_warning'] + html = "

#{article['trigger_warning_text']}

" + html + end + + file.content = Sanitize.fragment(html, Sanitize::Config::RELAXED) + + date = timestamp(article['updated_on']) + file.data.merge!( + 'sources' => article['sources'], + "date" => date, + "title" => article['title'], + "layout" => 'article', + "topics" => topics, + "days_ago" => (now - date).floor + ) + file.output + end + end + +end \ No newline at end of file diff --git a/about.md b/about.md new file mode 100644 index 0000000..de0a263 --- /dev/null +++ b/about.md @@ -0,0 +1,17 @@ +--- +layout: article +title: About This Site +--- + +This site is a text-only minimal version of [Beatroot News](https://app.beatrootnews.com/), a new news app by Freemedia Interactive Private Limited. + +It is maintained by [Nemo](https://github.com/captn3m0), and is meant as a minimal news website that you can check once a day. + +This text-only version is unaffiliated with Beatroot News or Freemedia Interactive Private Limited. The content is updated once every hour. + +## Curation Notes + +- The [home-page](/) only includes un-syndicated articles. +- Only articles from today and yesterday are shown. +- The design is based on [NPR's](http://text.npr.org/) text-only website. +- Trigger Warnings are shown in bold, prefixed to the article text. \ No newline at end of file diff --git a/favicon.png b/favicon.png new file mode 100644 index 0000000..305c0a4 Binary files /dev/null and b/favicon.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..503cbd2 --- /dev/null +++ b/index.html @@ -0,0 +1,26 @@ +--- +title: "Beatroot News: Text-only" +layout: default +--- +

+
+

{{page.title}}

+
+

{{site.time | date: "%A, %b, %e, %Y"}}

+{% for topic in site.topics %} +

{{topic | capitalize}}

+ +{% endfor %} +