Updated GabTrendsController, ShopController to use Request instead of Net

• Updated:
- GabTrendsController, ShopController to use Request instead of Net
This commit is contained in:
mgabdev 2020-07-07 16:01:51 -05:00
parent 2ae611d7ed
commit 0fdf762815
5 changed files with 88 additions and 23 deletions

View File

@ -11,14 +11,14 @@ class Api::V1::GabTrendsController < Api::BaseController
body = Redis.current.get("gabtrends:feed")
if body.nil?
uri = URI("https://trends.gab.com/trend-feed/json")
uri.query = URI.encode_www_form({})
res = Net::HTTP.get_response(uri)
if res.is_a?(Net::HTTPSuccess)
body = res.body
Redis.current.set("gabtrends:feed", res.body)
Redis.current.expire("gabtrends:feed", 1.hour.seconds)
Request.new(:get, "https://trends.gab.com/trend-feed/json").perform do |res|
if res.code == 200
body = res.body_with_limit
Redis.current.set("gabtrends:feed", body)
Redis.current.expire("gabtrends:feed", 1.hour.seconds)
else
body = nil
end
end
end
@ -27,14 +27,14 @@ class Api::V1::GabTrendsController < Api::BaseController
body = Redis.current.get("gabtrends:partner")
if body.nil?
uri = URI("https://trends.gab.com/partner")
uri.query = URI.encode_www_form({})
res = Net::HTTP.get_response(uri)
if res.is_a?(Net::HTTPSuccess)
body = res.body
Redis.current.set("gabtrends:partner", res.body)
Request.new(:get, "https://trends.gab.com/partner").perform do |res|
if res.code == 200
body = res.body_with_limit
Redis.current.set("gabtrends:partner", body)
Redis.current.expire("gabtrends:partner", 1.minute.seconds)
else
body = nil
end
end
end

View File

@ -13,14 +13,14 @@ class Api::V1::ShopController < Api::BaseController
body = Redis.current.get("gabstore:featuredproducts")
if body.nil?
uri = URI("https://shop.dissenter.com/product/group/json")
uri.query = URI.encode_www_form({})
res = Net::HTTP.get_response(uri)
if res.is_a?(Net::HTTPSuccess)
body = res.body
Redis.current.set("gabstore:featuredproducts", res.body)
Redis.current.expire("gabstore:featuredproducts", 15.minutes.seconds)
Request.new(:get, "https://shop.dissenter.com/product/group/json").perform do |res|
if res.code == 200
body = res.body_with_limit
Redis.current.set("gabstore:featuredproducts", body)
Redis.current.expire("gabstore:featuredproducts", 15.minutes.seconds)
else
body = nil
end
end
end

View File

@ -0,0 +1,32 @@
import NavigationBar from '../components/navigation_bar'
export default class IntroductionLayout extends PureComponent {
static propTypes = {
children: PropTypes.node,
title: PropTypes.string,
}
render() {
const { children, title } = this.props
return (
<div className={[_s.default, _s.width100PC, _s.heightMin100VH, _s.bgTertiary].join(' ')}>
<NavigationBar title={title} />
<div className={[_s.default, _s.flexRow, _s.width100PC].join(' ')}>
<div className={[_s.default, _s.width100PC].join(' ')}>
<main role='main'>
<div className={[_s.default, _s.mlAuto, _s.mrAuto].join(' ')}>
{children}
</div>
</main>
</div>
</div>
</div>
)
}
}

View File

@ -0,0 +1,17 @@
import PageTitle from '../features/ui/util/page_title'
import IntroductionLayout from '../layouts/introduction_layout'
export default class IntroductionPage extends PureComponent {
render() {
const { children } = this.props
return (
<IntroductionLayout>
<PageTitle path='Welcome to Gab' />
{children}
</IntroductionLayout>
)
}
}

16
app/models/shortcut.rb Normal file
View File

@ -0,0 +1,16 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: shortcuts
#
# id :bigint(8) not null, primary key
# account_id :bigint(8) not null
# shortcut_id :bigint(8) not null
# shortcut_type :string not null
# created_at :datetime not null
# updated_at :datetime
#
class Shortcut < ApplicationRecord
end