Skip to content

Commit

Permalink
Merge pull request #56 from wvuweb/dev
Browse files Browse the repository at this point in the history
Merge Dev
  • Loading branch information
zeroedin authored Feb 26, 2019
2 parents 1840a9f + e243d58 commit 4eea618
Show file tree
Hide file tree
Showing 15 changed files with 388 additions and 58 deletions.
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
source 'http://rubygems.org'

ruby "2.3.3"

gem 'rack'
gem 'webrick'
gem 'radius'
Expand Down
5 changes: 1 addition & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,5 @@ DEPENDENCIES
wannabe_bool
webrick

RUBY VERSION
ruby 2.3.3p222

BUNDLED WITH
1.14.6
1.15.4
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,20 @@ files: # files contains all the data fo
- ...

blog: # blog contains all the data for the <r:blog:{method} /> tags
name: String # <r:blog:name /> -- accepts a string
- id: Integer
name: String # <r:blog:name /> -- accepts a string
# blog articles much like pages are a repeating group of content for each article
articles: # each article is seperated by a dash
- article: # <r:blog:articles /> loops can access the following data in a <r:each />
name: String # <r:article:name /> -- accepts a string
title: String # <r:article:title /> -- accepts a string
created_by: # <r:article:author_full_name /> -- accepts two other objects
first_name: String # <r:article:author_first_name /> -- accepts a string
last_name: String # <r:article:author_last_name /> -- acccpts a string
content: String # <r:article:content /> -- accepts a string or | pipe character followed by HTML
published_at: 2 days ago # <r:article:published_at /> -- accepts a date string
- article:
...
- article:
...
articles: # each article is seperated by a dash
- article: # <r:blog:articles /> loops can access the following data in a <r:each />
name: String # <r:article:name /> -- accepts a string
title: String # <r:article:title /> -- accepts a string
created_by: # <r:article:author_full_name /> -- accepts two other objects
first_name: String # <r:article:author_first_name /> -- accepts a string
last_name: String # <r:article:author_last_name /> -- acccpts a string
content: String # <r:article:content /> -- accepts a string or | pipe character followed by HTML
published_at: 2 days ago # <r:article:published_at /> -- accepts a date string
- article:
...
- article:
...
```
51 changes: 51 additions & 0 deletions hammer/config/hammer
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
-----BEGIN RSA PRIVATE KEY-----
MIIJKQIBAAKCAgEAnrAtIqNk0/q6M132OgRpOYf2JXjlfAXcGx0fWuzwUSlPAIa8
HiC/V+QIcdxEPI4q2qq+Vd1nNqzznNIbm/g42PGe6jOT9B4QVTUEXV4hm2Q/nh1L
s5ab4XoG6vN3ZwxnwODCUpRVeAyCBuV4vnrMdgDgHJViupeHcaGPBMSeeACbpA/Z
6/zYh/sNXZ5OxEkUqbobOfclfOEEMAf/+flABgSS98jq5Eu8X6Y6VQL/Eug5bZpn
kXj48IO65nMWuRr+KDZo4S5Aiu1vSB7Ok2ps1P76QG5ikK2gkFCnXNIY1OnpKQmW
X+dYttR59XpDdP0ztX11HzDIGAy+fpMxXZIfLfc1qXUEEEX4+2qvJ60+9SLRpYiF
Gj3Miw2Tt9RZQFByTjjH54FoMMD4kxEodAQtFuQhk3ls855Gi93qLH5F2If/8Yx9
qQMhisLAQJXqqIEYL8SsyzdFZCRNQQEZWdi2a1pG1B4xt93nGk5S8gW3WLctCamI
Ek/0X1T23idAO+iIHJ2AGwLAUvFEDLjwPzcPck2YmyxT9+IfnHeEfxXf7anUA5qP
oEh3ryGDoJWX0ge7dx+3gXSvYVnwxypzo4FEgfOvkR0mLxtUtbHBz4VxR6MtFUrW
fX6JSesK9mhtxpiPDWmrnJbTB1mmofmvP54YClMMuxSzoufvA7R1DIWo2+ECAwEA
AQKCAgAZSoDXDW2Lb2FvwGD23C8dETNEw6DnhFORKrINnseqV8gUkGS49IUqb9h8
tRtW/12LHj1ZmADUMPpemwn1cLk2skOelfvVo1j9C4cXjmISzwZon8ip5a4QYI9r
sMPt84cxsWCnIqcAjBXJHZeB3DZr9DXDuHdUv8PBc3tEykVrYMVtf20+9DxaZ8O4
kPuCwxb8+gFO2rnpzj8JnKzKXVQ74Uy/GxF8sylhoS+YzvJyQ/qrIjmxcLNUOd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KlE1xDprr5Pgtaw5uyo6boRTY1ivAzEvSCPEDSUMgYV06CHj
-----END RSA PRIVATE KEY-----
58 changes: 44 additions & 14 deletions hammer/hammer_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,37 @@ def os
end


g = Git.open("../")
# g = Git.open("../")
hammer_branch_cmd = "cd ../ && git symbolic-ref --short HEAD"

begin
branch = g.lib.send(:command, "symbolic-ref --short HEAD")
ref = g.lib.send(:command, "rev-parse #{branch}")
remote = g.lib.send(:command, "rev-parse origin/#{branch}")
hammer_branch = `#{hammer_branch_cmd}`
hammer_ref_cmd = "cd ../ && git rev-parse #{hammer_branch}"
hammer_remote_cmd = "cd ../ && git ls-remote"
hammer_ref = `#{hammer_ref_cmd}`
hammer_remote = `#{hammer_remote_cmd}`

hammer_branch = hammer_branch.delete("\n")
hammer_ref = hammer_ref.delete("\n")

hammer_remote = hammer_remote.split("\n").collect{|ref| ref.split("\t")}
hammer_remote = hammer_remote.select{|remote| remote[1] == "refs/heads/#{hammer_branch}"}[0][0]

puts "Hammer is on branch: ".colorize(:light_white)+"#{hammer_branch}".colorize(:light_blue)
puts "Hammer Local #{hammer_branch} branch ref is at: ".colorize(:light_white)+"#{hammer_ref}".colorize(:light_blue)
puts "Hammer Remote #{hammer_branch} branch ref is at: ".colorize(:light_white)+"#{hammer_remote}".colorize(:light_blue)

if ref.to_s != remote.to_s
# branch = g.lib.send(:command, "symbolic-ref --short HEAD")
# ref = g.lib.send(:command, "rev-parse #{branch}")
# remote = g.lib.send(:command, "rev-parse origin/#{branch}")

if hammer_ref != hammer_remote
update_url = "https://github.com/wvuweb/hammer/wiki/Update"
puts " "
puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!".colorize(:red)
puts "!!!".colorize(:red)+" WARNING YOU ARE BEHIND ON HAMMER VERSIONS".colorize(:light_cyan)+" !!!".colorize(:red)
puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!".colorize(:red)
puts " "
puts "Repository is currently at ref: ".colorize(:light_white)+(ref.to_s+" ").colorize(:light_magenta)
puts "Remote is currently at ref: ".colorize(:light_white)+(remote.to_s+" ").colorize(:light_magenta)
# puts "Learn how to update Hammer at: ".colorize(:light_white)+update_url.colorize(:light_cyan)
puts " "
puts " "
puts "Update Hammer by using using the following command: ".colorize(:light_white)
puts " "
puts "vagrant hammer update".colorize(:light_green)
Expand All @@ -93,7 +106,7 @@ def os
puts " "
puts " "
end
rescue
rescue => e
puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!".colorize(:red)
puts "!!!".colorize(:red)+" COULD NOT CHECK HAMMER REPOSITORY FOR UPDATES".colorize(:light_cyan)+" !!!".colorize(:red)
puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!".colorize(:red)
Expand All @@ -103,10 +116,27 @@ def os
doc_root = options.directory
if File.directory?(doc_root+"/code")

code = Git.open(doc_root+"/code")
# code = Git.open(doc_root+"/code")

# Add identity files for bitbucket
File.chmod(0600,"./config/hammer")

puts "Adding Identity files to be able to access Code repository in bitbucket"
code_ref_cmd = " ssh-agent bash -c 'ssh-add ./config/hammer; cd #{doc_root+'/code'} && git rev-parse master'"
code_remote_cmd = "ssh-agent bash -c 'ssh-add ./config/hammer; cd #{doc_root+'/code'} && git ls-remote'"

begin
code_ref = g.lib.send(:command, "rev-parse master")
code_remote = g.lib.send(:command, "rev-parse origin/master")

code_ref = `#{code_ref_cmd}`
code_ref = code_ref.delete("\n")
code_remote = `#{code_remote_cmd}`
code_remote = code_remote.split("\n").collect{|ref| ref.split("\t")}.select{|remote| remote[1] == "refs/heads/master"}[0][0]

puts "Code Local repo ref is at: ".colorize(:light_white)+"#{code_ref}".colorize(:light_blue)
puts "Code Remote repo ref is at: ".colorize(:light_white)+"#{code_remote}".colorize(:light_blue)

#code_ref = g.lib.send(:command, "rev-parse master")
#code_remote = g.lib.send(:command, "rev-parse origin/master")

if code_ref.to_s != code_remote.to_s
puts " "
Expand Down
6 changes: 6 additions & 0 deletions hammer/services/tag_container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
require 'action_view'
require 'active_support/core_ext/string/output_safety'

require '../hammer/services/theme_asset_pipeline/parser.rb'
require '../hammer/services/theme_asset_pipeline/image.rb'
require '../hammer/services/theme_asset_pipeline/javascript.rb'
require '../hammer/services/theme_asset_pipeline/resource.rb'
require '../hammer/services/theme_asset_pipeline/style.rb'

class TagContainer

def self.tag(name, &block)
Expand Down
13 changes: 7 additions & 6 deletions hammer/services/tags/basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ class Basic < TagContainer
# options['mode'] = tag.globals.mode
#
# %w(no_self no_root text_only reverse).each do |i|
# binding.pry
# options[i] = options[i].to_b
# end
if tag.globals.context.data && tag.globals.context.data[:breadcrumbs]
Expand Down Expand Up @@ -456,11 +455,13 @@ def self.parse_date(str)

# cache [tag.cache_key, tag.globals.site, tag.globals.page], expires_in: cache_term_minutes.minutes do
begin
url = url = URI.parse(url)
request = req = Net::HTTP::Get.new(url.to_s)
response = Net::HTTP.start(url.host, url.port) {|http|
http.request(req)
}
uri = URI.parse(url)
response = Net::HTTP.start(uri.host, uri.port,
:use_ssl => uri.scheme == 'https') do |http|
request = Net::HTTP::Get.new uri
http.request request # Net::HTTPResponse object
end

#rescue raise(RuntimeTagError, "ERROR: Could not load the XML URL: #{url}")
rescue => e
return Hammer.error "Could not load the XML URL: #{url} due to #{e}"
Expand Down
35 changes: 21 additions & 14 deletions hammer/services/tags/blog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ class Blog < TagContainer
# tag.locals.blog ||= load_blog(tag)
# tag.expand
if tag.globals.context.data && tag.globals.context.data['blog']
tag.locals.blog = tag.globals.context.data['blog']
if tag.attr['id'] && tag.globals.context.data['blog'].class == Array

@blog = tag.globals.context.data['blog'].select{|w,v| w['id'].to_s ==(tag.attr['id']) }.first
else

@blog = tag.globals.context.data['blog'].first
end
end
tag.expand
end
Expand Down Expand Up @@ -93,14 +99,18 @@ class Blog < TagContainer
# tag.locals.blog ||= load_blog(tag)
# tag.locals.articles = filter_articles(tag, tag.locals.blog.children.published)
# tag.expand
# if tag.globals.context.data && tag.globals.context.data[:blog]

if tag.globals.context.data && tag.globals.context.data[:blog] && tag.globals.context.data[:blog][:articles]
tag.locals.articles = tag.globals.context.data[:blog][:articles]
begin
tag.locals.articles = @blog[:articles]
# end
tag.locals.articles = [] if tag.locals.articles.nil?
tag.locals.attributes = tag.attr
tag.expand
rescue
Hammer.error 'Blog Articles should be part of an array.'
end

tag.locals.articles = [] if tag.locals.articles.nil?
tag.locals.attributes = tag.attr
tag.expand
end

tag 'articles:each' do |tag|
Expand Down Expand Up @@ -179,8 +189,8 @@ class Blog < TagContainer
)
ActionView::Base.new.content_tag :ul, class: options[:ul_class] do

if tag.globals.context.data[:blog][:archive] && tag.globals.context.data[:blog][:archive][:monthly] && tag.globals.context.data[:blog][:archive][:monthly].count > 0
data = tag.globals.context.data[:blog][:archive][:monthly]
if @blog[:archive] && @blog[:archive][:monthly] && @blog[:archive][:monthly].count > 0
data = @blog[:archive][:monthly]
else
date_to = Date.parse(Chronic.parse('today').strftime("%Y-%m-%d").to_s)
date_from = Date.parse(Chronic.parse('4 months ago').strftime("%Y-%m-%d").to_s)
Expand Down Expand Up @@ -246,10 +256,8 @@ def load_blog(tag)
end

def load_article(tag)
# page = tag.globals.page
#page.type == 'ArticlePage' ? decorated_page(page) : nil
if tag.globals.context.data && tag.globals.context.data['blog'] && tag.globals.context.data['blog']['articles']
tag.globals.context.data['blog']['articles'].first
if tag.globals.context.data && tag.globals.context.data['blog'] && tag.globals.context.data['blog'].first['articles']
tag.globals.context.data['blog'].first['articles'].sample
else
content = <<-CONTENT
<p>#{Faker::Lorem.paragraph(2)}</p>
Expand All @@ -261,7 +269,7 @@ def load_article(tag)
:title => Faker::Lorem.sentence(1),
:created_by => { :first_name => Faker::Name.first_name, :last_name => Faker::Name.last_name },
:content => content,
:published_at => Random.rand(11).to_s+ "days ago"
:published_at => Random.rand(11).to_s+ " days ago"
}
tag.locals.article = article
article
Expand Down Expand Up @@ -300,7 +308,6 @@ def loop_over(tag, target)
# end
#
# output.flatten.join('')

if tag.locals.attributes['limit']
limit = tag.locals.attributes['limit'].to_i - 1
items = target[0..limit]
Expand Down
26 changes: 22 additions & 4 deletions hammer/services/tags/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,20 @@ class Page < TagContainer

if tag.globals.context.data && tag.globals.context.data['pages']
data = tag.globals.context.data['pages'].find { |h| h['id'] == tag.attr['id'].to_i }

puts "Processing tag get_page with page id #{data["id"]}".colorize(:light_blue)

oldcontext = tag.globals.context.data['page']

if data
newcontext = data
tag.expand(newcontext,oldcontext)
else
Hammer.error "key <em>pages:id</em> of #{tag.attr['id']} not found in mock_data file"
if tag.attr['id'].nil
Hammer.error "get_page tag attribute of id is nil"
else
Hammer.error "key <em>pages:id</em> of: #{tag.attr['id']} was not found in mock_data file"
end
end
else
Hammer.error "Set key <em>pages</em> in mock_data file"
Expand All @@ -196,7 +204,7 @@ class Page < TagContainer
tag.expand unless tag.globals.context.data['page']['default_page']
end

[:id, :name, :path, :slug, :meta_description, :title, :alternate_name, :depth, :created_at, :updated_at, :published_at].each do |attr|
[:id, :name, :path, :slug, :meta_description, :title, :alternate_name, :depth].each do |attr|
tag "page:#{attr.to_s}" do |tag|
# tag.locals.page.send(attr)
#{"}fix page:#{attr.to_s} tag"
Expand All @@ -208,6 +216,18 @@ class Page < TagContainer
end
end

[:created_at, :updated_at, :published_at].each do |attr|
tag "page:#{attr.to_s}" do |tag|
# tag.locals.page.send(attr)
#{"}fix page:#{attr.to_s} tag"
if tag.globals.context.data && tag.globals.context.data['page'] && tag.globals.context.data['page'][attr.to_s]
tag.globals.context.data['page'][attr.to_s]
else
Random.rand(11).to_s+ " days ago"
end
end
end

tag 'page:url' do |tag|
# format = tag.attr['format'].to_s.strip
# format = nil if format.downcase =~ /\Ahtml?\Z/
Expand Down Expand Up @@ -270,7 +290,6 @@ class Page < TagContainer
else
Hammer.error "Set key <em>page</em> in mock_data file"
end
#binding.pry#"fix page:first_non_blank_attr tag"
end

tag 'page:content' do |tag|
Expand Down Expand Up @@ -310,7 +329,6 @@ class Page < TagContainer
# tag.locals.page_template = tag.locals.page.template
# tag.expand
if tag.globals.context.data && tag.globals.context.data["page"]
# binding.pry
if tag.globals.context.data["page"]["template"]
tag.locals.page_template = tag.globals.context.data["page"]["template"]
end
Expand Down
7 changes: 7 additions & 0 deletions hammer/services/tags/theme_asset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ class ThemeAsset < TagContainer
output
end

tag 'stylesheet_content' do |tag|
css_name = tag.attr['name'].strip
css_name += '.css' unless css_name.ends_with?('.css')
pipe = ThemeAssetPipeline::Style.new(tag.globals.context.theme_root, css_name)
pipe.content
end

tag 'stylesheet_url' do |tag|
doc_root = tag.globals.context.server.config[:DocumentRoot]

Expand Down
Loading

0 comments on commit 4eea618

Please sign in to comment.