-
Notifications
You must be signed in to change notification settings - Fork 41
IFSC Website #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
IFSC Website #32
Changes from all commits
c88b6d9
fab3777
0438063
46c1490
0327fe6
733f369
dc5ed49
b09e858
89c09e0
9365741
9b565ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| vendor | ||
| vendor | ||
| public/sitemap*.xml* |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| # Gemfile used in the build docker container | ||
| source "https://rubygems.org" | ||
|
|
||
| gem "redis" | ||
| gem "redis" | ||
| gem "sitemap_generator" | ||
| gem 'to_slug', '~> 1.0', '>= 1.0.8' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,19 @@ | ||
| GEM | ||
| remote: https://rubygems.org/ | ||
| specs: | ||
| redis (4.1.3) | ||
| builder (3.2.4) | ||
| redis (4.2.5) | ||
| sitemap_generator (6.1.2) | ||
| builder (~> 3.0) | ||
| to_slug (1.0.8) | ||
|
|
||
| PLATFORMS | ||
| ruby | ||
|
|
||
| DEPENDENCIES | ||
| redis | ||
| sitemap_generator | ||
| to_slug (~> 1.0, >= 1.0.8) | ||
|
|
||
| BUNDLED WITH | ||
| 2.0.2 | ||
| 2.2.7 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,4 +58,4 @@ DEPENDENCIES | |
| thin | ||
|
|
||
| BUNDLED WITH | ||
| 2.2.6 | ||
| 2.2.7 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| #!/usr/bin/dumb-init /bin/sh | ||
| cd /app | ||
| redis-server --daemonize yes | ||
| bundle exec rackup --host 0.0.0.0 --port 3000 | ||
| bundle exec rackup --host 0.0.0.0 --port 3000 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,59 @@ | ||
| require 'json' | ||
| require 'redis' | ||
| require 'benchmark' | ||
| require 'to_slug' | ||
| require 'sitemap_generator' | ||
|
|
||
| redis = Redis.new | ||
|
|
||
| def log(msg) | ||
| puts "[+] (#{Time.now.strftime('%r')}) #{msg}" | ||
| end | ||
|
|
||
| def add_to_sitemap(sitemap, ifsc, data) | ||
| url = nil | ||
| if data['BANK'] && data['BRANCH'] | ||
| url = "/#{data['BANK'].to_s.to_slug}/#{data['BRANCH'].to_s.to_slug}/#{ifsc}" | ||
| end | ||
| if url | ||
| config = { lastmod: Time.now, changefreq: 'monthly', priority: 0.3 } | ||
| sitemap.add url, config | ||
| end | ||
| end | ||
|
|
||
| Benchmark.bm(18) do |bm| | ||
| bm.report('Ingest:') do | ||
| Dir.glob('data/*.json') do |file| | ||
| log "Processing #{file}" | ||
| bank = File.basename file, '.json' | ||
| if Regexp.new('[A-Z]{4}').match(bank) | ||
| data = JSON.parse File.read file | ||
| data.each do |ifsc, d| | ||
| # Remove the extra keys from the JSON files | ||
| d.delete_if { |key| %w[BANK IFSC].include? key } | ||
| redis.hmset ifsc, *d | ||
| # CHANGE TO .com before merging | ||
| SitemapGenerator::Sitemap.default_host = 'https://ifsc.stage.razorpay.in' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. get it from config may be? |
||
| SitemapGenerator::Sitemap.create_index = true | ||
|
|
||
| SitemapGenerator::Sitemap.create do |s| | ||
| s.add '/', changefreq: 'daily', priority: 0.9 | ||
| Dir.glob('data/*.json') do |file| | ||
| log "Processing #{file}" | ||
| bank = File.basename file, '.json' | ||
| if Regexp.new('[A-Z]{4}').match(bank) | ||
| data = JSON.parse File.read file | ||
| data.each do |ifsc, d| | ||
| begin | ||
| add_to_sitemap(s, ifsc, d) | ||
| rescue Exception => e | ||
| puts e | ||
| end | ||
|
|
||
| # Remove the extra keys from the JSON files | ||
| d.delete_if { |key| %w[BANK IFSC].include? key } | ||
| redis.hmset ifsc, *d | ||
| end | ||
| log "Processed #{data.size} entries" | ||
| end | ||
| log "Processed #{data.size} entries" | ||
| end | ||
| end | ||
| end | ||
|
|
||
| bm.report('Dump:') do | ||
| redis.save | ||
| end | ||
| end | ||
|
|
||
| log('Data saved to Redis') | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Sitemap: https://ifsc.stage.razorpay.in/sitemap.xml.gz | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. put the prod url. until we submit the sitemap, search engines will not crawl i guess
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
| <title>Razorpay IFSC Toolkit</title> | ||
| <link href='/main.css' rel='stylesheet' type='text/css'> | ||
| <link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'> | ||
| <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro' rel='stylesheet' type='text/css'> | ||
| <link rel="shortcut icon" href="https://razorpay.com/favicon.png" type="image/png"> | ||
| </head> | ||
| <body class="home-template"> | ||
| <header class="main-header"> | ||
| <ul id="nav"> | ||
| <div class="container"> | ||
| <li><a id="logo-link" href="https://razorpay.com/?ref=ifsc"></a></li> | ||
| <li><a href="https://razorpay.com/blog/">Blog</a></li> | ||
| <div class="middle-links"> | ||
| <li><a href="https://razorpay.com/features/?ref=ifsc">Features</a></li> | ||
| <li><a href="https://razorpay.com/demo/?ref=ifsc">Demo</a></li> | ||
| <li><a href="https://docs.razorpay.com" target="_blank">Docs</a></li> | ||
| </div> | ||
| <div class="float-right"> | ||
| <li><a href="https://dashboard.razorpay.com/#/access/signin" class="login-link">Log In</a></li> | ||
| <li><a href="https://dashboard.razorpay.com/#/access/signup?ref=ifsc" class="btn login-link">Sign Up</a></li> | ||
| </div> | ||
| </div> | ||
| </ul> | ||
| </header> | ||
| <div class='container'> | ||
| <table class="ifsc-table"> | ||
| <tr> | ||
| <th>IFSC</th> | ||
| <td><%= data['IFSC']%></td> | ||
| </tr> | ||
| <tr> | ||
| <th>Address</th> | ||
| <td><%= data['ADDRESS']%></td> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, add https://schema.org/ context schema so that search engines recognize the data easily |
||
| </tr> | ||
| <tr> | ||
| <th>Contact</th> | ||
| <td><%= data['CONTACT']%></td> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. some of the data is null and it's not sanitized properly.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, design is WIP for now. |
||
| </tr> | ||
| <tr> | ||
| <th>City</th> | ||
| <td><%= data['CITY']%></td> | ||
| </tr> | ||
| <tr> | ||
| <th>District</th> | ||
| <td><%= data['DISTRICT']%></td> | ||
| </tr> | ||
| <tr> | ||
| <th>State</th> | ||
| <td><%= data['STATE']%></td> | ||
| </tr> | ||
| <tr> | ||
| <th>RTGS</th> | ||
| <td><%= data['RTGS'] ? "Yes" : "No" %></td> | ||
| </tr> | ||
| <tr> | ||
| <th>Bank</th> | ||
| <td><%= data['BANK']%> <code>(<%=data['BANKCODE']%>)</code></td> | ||
| </tr> | ||
| </table> | ||
| </div> | ||
| </body> | ||
| </html> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge both if's