Permalink
Browse files

Add shortlinks

  • Loading branch information...
adamdawkins committed Jan 21, 2019
1 parent f5e4ed6 commit 12e8c0ad9e7ac8e93f133c9d90d83d01ef87f47e
2 .env
@@ -1,2 +1,4 @@
ADAM_PASSWORD=password
ADAM_USERNAME=adamblaesuthnoeudawkins
FULL_URL=adamdawkins.uk.test
SHORT_URL=dwks.me.test
@@ -25,3 +25,4 @@

# Ignore master key for decrypting credentials and more.
/config/master.key
.powenv
@@ -0,0 +1,2 @@
adamdawkins.uk
dwks.me
@@ -0,0 +1,6 @@
class ShortDomainsController < ApplicationController
def post
@post = Post.find(params[:id])
redirect_to long_post_path(@post.params), host: ENV['FULL_URL']
end
end
@@ -0,0 +1,2 @@
module ShortDomainsHelper
end
@@ -1,24 +1,30 @@
Rails.application.routes.draw do
root to: 'notes#index'
constraints host: ENV['SHORT_URL'] do
get '/:id' => 'short_domains#post'
match "/(*path)", to: redirect {|p, req| "//#{ENV['FULL_URL']}#{req.fullpath}"}, via: [:get, :head]
end

get 'login', to: 'sessions#new'
get 'adam', to: 'adam/notes#new'
constraints host: ENV['FULL_URL'] do
root to: 'notes#index'

resources :sessions, only: [:new, :create, :destroy]
get 'login', to: 'sessions#new'
get 'adam', to: 'adam/notes#new'

namespace :adam do
resources :notes
resources :articles
put "notes/:id/publish", to: "notes#publish", as: "publish_note"
put "articles/:id/publish", to: "articles#publish", as: "publish_article"
end
namespace :adam do
resources :notes
resources :articles
put "notes/:id/publish", to: "notes#publish", as: "publish_note"
put "articles/:id/publish", to: "articles#publish", as: "publish_article"
end

resources :articles, only: :index
resources :sessions, only: [:new, :create, :destroy]

get ':year/:month/:day/:slug', to: 'posts#show', as: :long_post
get 'indiemark', to: 'indiemarks#index'
get ':year/:month/:day/:slug', to: 'posts#show', as: :long_post
get 'indiemark', to: 'indiemarks#index'

resources :notes
resources :articles, only: :index
resources :notes

get '*page', to: 'pages#show'
get '*page', to: 'pages#show'
end
end
@@ -0,0 +1,5 @@
require 'rails_helper'

RSpec.describe ShortDomainsController, type: :controller do

end
@@ -0,0 +1,15 @@
require 'rails_helper'

# Specs in this file have access to a helper object that includes
# the ShortDomainsHelper. For example:
#
# describe ShortDomainsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe ShortDomainsHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

0 comments on commit 12e8c0a

Please sign in to comment.