Skip to content

Commit

Permalink
add scaffold for text page
Browse files Browse the repository at this point in the history
  • Loading branch information
schoetty committed Oct 21, 2014
0 parents commit 3457e1b
Show file tree
Hide file tree
Showing 21 changed files with 294 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
*.gem
*.rbc
*.sqlite3
.bundle
.config
.yardoc
.idea
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
log
Gemfile.lock
1 change: 1 addition & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vendor/assets/javascripts/**
22 changes: 22 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"browser": true,
"undef": true,
"immed": true,
"trailing": true,
"globals": {
"jQuery": true,
"$": true,
"Backbone": true,
"Cocktail": true,
"_": true,
"vjs": true,
"Audio5js": true,
"I18n": true,

"pageflow": true,
"editor": true,

"confirm": true,
"alert": true
}
}
10 changes: 10 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in chart.gemspec
gemspec

# Rails 4 compat
gem 'activeadmin', :git => 'https://github.com/codevise/active_admin.git', :branch => 'rails4'
gem 'ransack'
gem 'inherited_resources', '1.4.1'
gem 'formtastic', '2.3.0.rc2'
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Pageflow Text Page

Page type to display large texts on a page.

## Installation

Add this line to your application's `Gemfile`:

gem 'pageflow-text-page'

Register the page type inside the configure block in `config/initializers/pageflow.rb`

Pageflow.configure do |config|
config.register_page_type(Pageflow::TextPage::PageType.new)
end

Include javascripts and stylesheets:

# app/assets/javascripts/pageflow/application.js
//= require pageflow/text_page

# app/assets/javascripts/pageflow/editor.js
//= require pageflow/text_page/editor

# app/assets/stylesheets/pageflow/application.css.scss
@import "pageflow/text_page";

Mount the routes in `config/routes.rb`:

authenticated do
mount Pageflow::TextPage::Engine, :at => '/text_page'
end

Install dependencies:

bundle install

Migrate the database:

bundle exec rake db:migrate

Restart the application server.

## Troubleshooting

If you run into problems while installing the page type, please also refer to the
[Troubleshooting](https://github.com/codevise/pageflow/wiki/Troubleshooting) wiki
page in the [Pageflow repository](https://github.com/codevise/pageflow). If that
doesn't help, consider
[filing an issue](https://github.com/codevise/pageflow-text-page/issues).
7 changes: 7 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end

Bundler::GemHelper.install_tasks
Binary file added app/assets/images/pageflow/ov-text_page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/assets/javascript/pageflow/text_page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//= require_self
//= require ./text_page/page_type

pageflow.textPage = pageflow.textPage || {};
12 changes: 12 additions & 0 deletions app/assets/javascript/pageflow/text_page/editor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//= require_self

//= require_tree ./editor/models
//= require_tree ./editor/collections
//= require_tree ./editor/routers
//= require_tree ./editor/controllers
//= require_tree ./editor/templates
//= require_tree ./editor/views

//= require ./editor/config

pageflow.textPage = pageflow.textPage || {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pageflow.textPage.TextPageEmbeddedView = Backbone.Marionette.View.extend({
modelEvents: {
'change': 'update'
},

render: function() {

this.update();
return this;
},

update: function() {
}
});
50 changes: 50 additions & 0 deletions app/assets/javascript/pageflow/text_page/page_type.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*global IScroll*/

pageflow.pageType.register('text_page', _.extend({
prepareNextPageTimeout: 0,

enhance: function(pageElement, configuration) {},

resize: function(pageElement, configuration) {},

prepare: function(pageElement, configuration) {},

preload: function(pageElement, configuration) {
return pageflow.preload.backgroundImage(pageElement.find('.background_image'));
},

activating: function(pageElement, configuration) {},

activated: function(pageElement, configuration) {},

deactivating: function(pageElement, configuration) {},

deactivated: function(pageElement, configuration) {},

update: function(pageElement, configuration) {
pageElement.find('h2 .tagline').text(configuration.get('tagline') || '');
pageElement.find('h2 .title').text(configuration.get('title') || '');
pageElement.find('h2 .subtitle').text(configuration.get('subtitle') || '');
pageElement.find('.contentText p').html(configuration.get('text') || '');

this.updateCommonPageCssClasses(pageElement, configuration);

pageElement.find('.shadow').css({
opacity: configuration.get('gradient_opacity') / 100
});
},

embeddedEditorViews: function() {
return {
'.background_image': {
view: pageflow.BackgroundImageEmbeddedView,
options: {propertyName: 'background_image_id'}
},

'.text-page': {
view: pageflow.textPage.ListEmbeddedView,
options: {propertyName: 'linked_text_page_perma_ids'}
}
};
}
}, pageflow.commonPageCssClasses));
3 changes: 3 additions & 0 deletions app/assets/stylesheets/pageflow/text_page.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@include pageflow-page-type(text_page);

.text-page { }
23 changes: 23 additions & 0 deletions app/views/pageflow/text_page/page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="blackLayer"></div>
<div class="content_and_background textPage">

<div class="content">
<div class="scroller">
<div>
<div class="contentWrapper">
<div class="page_header">
<h2>
<span class="tagline"><%= configuration['tagline'] %></span>
<span class="title"><%= configuration['title'] %></span>
<span class="subtitle"><%= configuration['subtitle'] %></span>
</h2>
<%= background_image_tag(configuration['background_image_id'], {:class => "print_image"}) %>
</div>
<div class="contentText">
<p><%= raw configuration['text'] %></p>
</div>
</div>
</div>
</div>
</div>
</div>
7 changes: 7 additions & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
de:
pageflow:
text_page:
page_type_name: "Text Seite"
activerecord:
attributes:
"pageflow/page":
5 changes: 5 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Pageflow::TextPage::Engine.routes.draw do
resources :entries, only: [], shallow: true do
resources :sites
end
end
6 changes: 6 additions & 0 deletions lib/pageflow-text-page.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require 'pageflow/text_page/engine'

module Pageflow
module TextPage
end
end
18 changes: 18 additions & 0 deletions lib/pageflow/text_page/engine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Pageflow
module TextPage
class Engine < Rails::Engine
isolate_namespace Pageflow::TextPage

config.autoload_paths << File.join(config.root, 'lib')

config.generators do |g|
g.test_framework :rspec,:fixture => false
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
g.assets false
g.helper false
end
end
end
end


15 changes: 15 additions & 0 deletions lib/pageflow/text_page/page_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Pageflow
module TextPage
class PageType < Pageflow::PageType
name 'text_page'

def revision_components
[Site]
end

def view_helpers
[SitesHelper]
end
end
end
end
27 changes: 27 additions & 0 deletions pageflow-text-page.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# coding: utf-8

Gem::Specification.new do |spec|
spec.name = "pageflow-text-page"
spec.version = "0.0.1"
spec.authors = ["Tim Fischbach"]
spec.email = ["[email protected]"]
spec.summary = "Pageflow Page Type text pages"
spec.homepage = ""
spec.license = "MIT"

spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.add_runtime_dependency "pageflow"

# Using translations from rails locales in javascript code.
spec.add_runtime_dependency 'i18n-js'

spec.add_development_dependency "bundler"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec-rails", "~> 2.0"
spec.add_development_dependency 'factory_girl_rails'
spec.add_development_dependency "sqlite3"
end

0 comments on commit 3457e1b

Please sign in to comment.