SlideShare ist ein Scribd-Unternehmen logo
1 von 30
Downloaden Sie, um offline zu lesen
Wysiwig on Rails
Roppongi.rb#1
@__timakin__ / timakin
Hello!
• timakin / @__timakin__
• Ruby / Node / Go
• https://medium.com/@timakin
• tech-savvy.hatenablog.com
Wysiwig
Wysiwig
•
•
•
•
Wysiwyg
•
•
•
• edit / view
Wysiwig on Rails
Wysiwyg Rails
• CKE Editor
• Squire
• Froala Editor
• Bootsy
• Redactor
• Medium-Editor
CKE Editor
CKE Editor
•
• WordPress
• Rails Carrierwave/PaperClip
• Plugin Rails config
•
Squire
Squire
•
•
•
textarea
iframe
Froala Editor
Froala Editor
•
•
• S3 ( or Froala
Storage )
• input
Bootsy
Bootsy
• Rails i18n
• Squire
• Carrierwave bootstrap-wysihtml5
Redactor
Redactor
•
• Video insert (Embed tag ) / Table
view / File upload
•
Medium-Editor
Medium-Editor
• Medium
•
• edit
Wysiwyg Rails
• CKE Editor
• Squire
• Froala Editor
• Bootsy
• Redactor
• Medium-Editor
Wysiwyg Rails
• CKE Editor
• Squire
• Froala Editor
• Bootsy
• Redactor
• Medium-Editor
Wysiwyg Rails
• CKE Editor
• Squire
• Froala Editor
• Bootsy
• Redactor
• Medium-Editor
Dante-Editor
Dante-Editor
• Medium-Editor Medium
• Image upload, video, social embed /
• iframe
url embedly
• S3 API js
• div value form hidden_field
• gem
image upload
class ApiController < ApplicationController
protect_from_forgery with: :null_session
def upload_image
s3 = Aws::S3::Resource.new(region: ENV['AWS_REGION'], access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'])
case Rails.env
when 'production'
obj = s3.bucket(ENV['SACKET_FOG_PRODUCTION_DIRECTORY']).object("images/embedded/
#{SecureRandom.hex(8)}")
when 'staging'
obj = s3.bucket(ENV['SACKET_FOG_STAGING_DIRECTORY']).object("images/embedded/#{SecureRandom.hex(8)}")
when 'development'
obj = s3.bucket(ENV['SACKET_FOG_STAGING_DIRECTORY']).object("images/embedded/#{SecureRandom.hex(8)}")
end
obj.upload_file(params[:file].tempfile, acl: 'public-read')
render json: { status: :ok, data: obj.public_url }
end
end
form
editor = new Dante.Editor(
{
el: "#editor",
disable_title: true,
upload_url: "/api/upload_image",
base_widgets: ["uploader", "embed"],
oembed_url: "http://api.embed.ly/1/oembed?key=hogehoge"
}
);
editor.start()
$(document).ready(function(){
$("#editor").bind("input properchange", function(){
$("#text_" + $(this).attr("data-field-id")).val($(this).html())
});
});
#
var embedTemplate = function() {
return "<figure contenteditable='false' class='graf--figure graf--iframe
graf--first' name='504e' tabindex='0'> <div class='iframeContainer'>
<iframe frameborder='0' width='700' height='393' data-media-id='' src=''
data-height='480' data-width='854'> </iframe> </div> <figcaption
contenteditable='true' data-default-value='Type caption for embed
(optional)' class='imageCaption'> <a rel='nofollow' class='markup--anchor
markup--figure-anchor' data-href='' href='' target='_blank'> </a> </
figcaption> </figure>";
};
var oembed_url = "http://api.embed.ly/1/oembed?
key=c6fc4f62de674f8a8ee60a7cbea1e13d&url=";
$(function(){
var node = $(".is-embedable");
var node_name = node.attr('name');
if (node.text())
{
console.log(node.text());
return $.getJSON("" + oembed_url + (node.text())).success((function(_this) {
return function(data) {
var iframe_src, replaced_node, tmpl, url;
var node = $("[name=" + node_name + "]");
node.hide();
iframe_src = $(data.html).prop("src");
tmpl = $(embedTemplate());
tmpl.attr("name", node.attr("name"));
$(node).replaceWith(tmpl);
replaced_node = $(".graf--iframe[name=" + (node.attr("name")) + "]");
replaced_node.find("iframe").attr("src", iframe_src);
url = data.url || data.author_url;
replaced_node.find(".markup--anchor").attr("href", url).text(url);
};
})(this)).error((function(_this) {
return function(res) {
console.log(res);
};
})(this));
}
});
•
Dante-Editor
• Rails gem
Carrierwave
js

Weitere ähnliche Inhalte

Was ist angesagt?

SPSNJ 2014: EmberJS & SharePoint
SPSNJ 2014: EmberJS & SharePointSPSNJ 2014: EmberJS & SharePoint
SPSNJ 2014: EmberJS & SharePoint
Greg Hurlman
 
Ember and SharePoint
Ember and SharePointEmber and SharePoint
Ember and SharePoint
Greg Hurlman
 

Was ist angesagt? (20)

Making maven and grunt play nice
Making maven and grunt play niceMaking maven and grunt play nice
Making maven and grunt play nice
 
eMusic: WordPress in the Enterprise
eMusic: WordPress in the EnterpriseeMusic: WordPress in the Enterprise
eMusic: WordPress in the Enterprise
 
[Start] Playing
[Start] Playing[Start] Playing
[Start] Playing
 
SPSNJ 2014: EmberJS & SharePoint
SPSNJ 2014: EmberJS & SharePointSPSNJ 2014: EmberJS & SharePoint
SPSNJ 2014: EmberJS & SharePoint
 
2010.09.02 LT Doc fluxflex on JAWS-UG
2010.09.02 LT Doc fluxflex on JAWS-UG2010.09.02 LT Doc fluxflex on JAWS-UG
2010.09.02 LT Doc fluxflex on JAWS-UG
 
Riding IronRuby on Rails
Riding IronRuby on RailsRiding IronRuby on Rails
Riding IronRuby on Rails
 
Ember and SharePoint
Ember and SharePointEmber and SharePoint
Ember and SharePoint
 
ASP.NET MVC
ASP.NET MVCASP.NET MVC
ASP.NET MVC
 
Signature
SignatureSignature
Signature
 
Working with Git
Working with GitWorking with Git
Working with Git
 
In-house web automation?
In-house web automation?In-house web automation?
In-house web automation?
 
Better framework, better life
Better framework, better lifeBetter framework, better life
Better framework, better life
 
Better Framework Better Life
Better Framework Better LifeBetter Framework Better Life
Better Framework Better Life
 
WordPress Development Environments
WordPress Development EnvironmentsWordPress Development Environments
WordPress Development Environments
 
DeveloperDeveloperDeveloper! Sydney 2012
DeveloperDeveloperDeveloper! Sydney 2012DeveloperDeveloperDeveloper! Sydney 2012
DeveloperDeveloperDeveloper! Sydney 2012
 
Building Elixir App Release with Distillery and Docker
Building Elixir App Release with Distillery and DockerBuilding Elixir App Release with Distillery and Docker
Building Elixir App Release with Distillery and Docker
 
2015 WordCamp Maine Keynote
2015 WordCamp Maine Keynote2015 WordCamp Maine Keynote
2015 WordCamp Maine Keynote
 
Angular2 + AWS Lambdaでサーバサイドレンダリングしてみた
Angular2 + AWS LambdaでサーバサイドレンダリングしてみたAngular2 + AWS Lambdaでサーバサイドレンダリングしてみた
Angular2 + AWS Lambdaでサーバサイドレンダリングしてみた
 
Live Coverage at The New York Times
Live Coverage at The New York TimesLive Coverage at The New York Times
Live Coverage at The New York Times
 
Deployment Nirvana
Deployment NirvanaDeployment Nirvana
Deployment Nirvana
 

Andere mochten auch

Etherem ~ agvm
Etherem ~ agvmEtherem ~ agvm
Etherem ~ agvm
gha sshee
 

Andere mochten auch (20)

Concept of BlockChain & Decentralized Application
Concept of BlockChain & Decentralized ApplicationConcept of BlockChain & Decentralized Application
Concept of BlockChain & Decentralized Application
 
お前なんかハッカーじゃない╭( ・ㅂ・)و ̑̑
お前なんかハッカーじゃない╭( ・ㅂ・)و ̑̑お前なんかハッカーじゃない╭( ・ㅂ・)و ̑̑
お前なんかハッカーじゃない╭( ・ㅂ・)و ̑̑
 
Excelの話
Excelの話Excelの話
Excelの話
 
Blockchain: The Information Technology of the Future
Blockchain: The Information Technology of the FutureBlockchain: The Information Technology of the Future
Blockchain: The Information Technology of the Future
 
アクセシビリティはじめました
アクセシビリティはじめましたアクセシビリティはじめました
アクセシビリティはじめました
 
BCU30 - Webでできるマルチメディア表現
BCU30 - Webでできるマルチメディア表現BCU30 - Webでできるマルチメディア表現
BCU30 - Webでできるマルチメディア表現
 
Serverside ES6@Livesense technight
Serverside ES6@Livesense technightServerside ES6@Livesense technight
Serverside ES6@Livesense technight
 
機械学習で大事なことをミニGunosyをつくって学んだ╭( ・ㅂ・)و ̑̑ 
機械学習で大事なことをミニGunosyをつくって学んだ╭( ・ㅂ・)و ̑̑ 機械学習で大事なことをミニGunosyをつくって学んだ╭( ・ㅂ・)و ̑̑ 
機械学習で大事なことをミニGunosyをつくって学んだ╭( ・ㅂ・)و ̑̑ 
 
日本のIT市場のトピックス
日本のIT市場のトピックス日本のIT市場のトピックス
日本のIT市場のトピックス
 
Etherem ~ agvm
Etherem ~ agvmEtherem ~ agvm
Etherem ~ agvm
 
Ethereum @ descon 2016
Ethereum @ descon 2016Ethereum @ descon 2016
Ethereum @ descon 2016
 
Dapps for Web Developers Aberdeen Techmeetup
Dapps for Web Developers Aberdeen TechmeetupDapps for Web Developers Aberdeen Techmeetup
Dapps for Web Developers Aberdeen Techmeetup
 
Solidity intro
Solidity introSolidity intro
Solidity intro
 
Etherisc Versicherung neu erfinden
Etherisc Versicherung neu erfindenEtherisc Versicherung neu erfinden
Etherisc Versicherung neu erfinden
 
Vision for a health blockchain
Vision for a health blockchainVision for a health blockchain
Vision for a health blockchain
 
Introduction to Idea
Introduction to IdeaIntroduction to Idea
Introduction to Idea
 
"Performance Analysis of In-Network Caching in Content-Centric Advanced Meter...
"Performance Analysis of In-Network Caching in Content-Centric Advanced Meter..."Performance Analysis of In-Network Caching in Content-Centric Advanced Meter...
"Performance Analysis of In-Network Caching in Content-Centric Advanced Meter...
 
The Ethereum ÐApp IDE: Mix
The Ethereum ÐApp IDE: MixThe Ethereum ÐApp IDE: Mix
The Ethereum ÐApp IDE: Mix
 
NodeJS Blockchain.info Wallet
NodeJS Blockchain.info WalletNodeJS Blockchain.info Wallet
NodeJS Blockchain.info Wallet
 
Everything dApp (Blockchain University Module II)
Everything dApp (Blockchain University Module II)Everything dApp (Blockchain University Module II)
Everything dApp (Blockchain University Module II)
 

Ähnlich wie Wysiwig on Rails

[.Net开发交流会][2010.06.19]better framework better life(吕国宁)
[.Net开发交流会][2010.06.19]better framework better life(吕国宁)[.Net开发交流会][2010.06.19]better framework better life(吕国宁)
[.Net开发交流会][2010.06.19]better framework better life(吕国宁)
Shanda innovation institute
 
Codestrong 2012 breakout session alloy (mvc) app framework overview
Codestrong 2012 breakout session   alloy (mvc) app framework overviewCodestrong 2012 breakout session   alloy (mvc) app framework overview
Codestrong 2012 breakout session alloy (mvc) app framework overview
Axway Appcelerator
 
Single Page Application Development with backbone.js and Simple.Web
Single Page Application Development with backbone.js and Simple.WebSingle Page Application Development with backbone.js and Simple.Web
Single Page Application Development with backbone.js and Simple.Web
Chris Canal
 
Project Tools in Web Development
Project Tools in Web DevelopmentProject Tools in Web Development
Project Tools in Web Development
kmloomis
 

Ähnlich wie Wysiwig on Rails (20)

Rapid development with Rails
Rapid development with RailsRapid development with Rails
Rapid development with Rails
 
Contributing to rails
Contributing to railsContributing to rails
Contributing to rails
 
Impression of Rails 3
Impression of Rails 3Impression of Rails 3
Impression of Rails 3
 
Plone for Education: Bibliographies
Plone for Education: BibliographiesPlone for Education: Bibliographies
Plone for Education: Bibliographies
 
OSDC 2013 | Introduction into Chef by Andy Hawkins
OSDC 2013 | Introduction into Chef by Andy HawkinsOSDC 2013 | Introduction into Chef by Andy Hawkins
OSDC 2013 | Introduction into Chef by Andy Hawkins
 
44 Slides About 22 Modules
44 Slides About 22 Modules44 Slides About 22 Modules
44 Slides About 22 Modules
 
WordPress Rest API
WordPress Rest APIWordPress Rest API
WordPress Rest API
 
[.Net开发交流会][2010.06.19]better framework better life(吕国宁)
[.Net开发交流会][2010.06.19]better framework better life(吕国宁)[.Net开发交流会][2010.06.19]better framework better life(吕国宁)
[.Net开发交流会][2010.06.19]better framework better life(吕国宁)
 
Scaling with swagger
Scaling with swaggerScaling with swagger
Scaling with swagger
 
Alloy - Codestrong 2012
Alloy - Codestrong 2012Alloy - Codestrong 2012
Alloy - Codestrong 2012
 
Codestrong 2012 breakout session alloy (mvc) app framework overview
Codestrong 2012 breakout session   alloy (mvc) app framework overviewCodestrong 2012 breakout session   alloy (mvc) app framework overview
Codestrong 2012 breakout session alloy (mvc) app framework overview
 
Ship It ! with Ruby/ Rails Ecosystem
Ship It ! with Ruby/ Rails EcosystemShip It ! with Ruby/ Rails Ecosystem
Ship It ! with Ruby/ Rails Ecosystem
 
Managing Multiple WordPress Websites in 2017
Managing Multiple WordPress Websites in 2017Managing Multiple WordPress Websites in 2017
Managing Multiple WordPress Websites in 2017
 
Selenium WebDriverを利用したサンプルアプリケーションのテスト
Selenium WebDriverを利用したサンプルアプリケーションのテストSelenium WebDriverを利用したサンプルアプリケーションのテスト
Selenium WebDriverを利用したサンプルアプリケーションのテスト
 
Alloy Framework
Alloy FrameworkAlloy Framework
Alloy Framework
 
Azureサーバーレスで行う情報のスクリーニング
Azureサーバーレスで行う情報のスクリーニングAzureサーバーレスで行う情報のスクリーニング
Azureサーバーレスで行う情報のスクリーニング
 
Single Page Application Development with backbone.js and Simple.Web
Single Page Application Development with backbone.js and Simple.WebSingle Page Application Development with backbone.js and Simple.Web
Single Page Application Development with backbone.js and Simple.Web
 
Project Tools in Web Development
Project Tools in Web DevelopmentProject Tools in Web Development
Project Tools in Web Development
 
海纳百川,有容乃大
海纳百川,有容乃大海纳百川,有容乃大
海纳百川,有容乃大
 
Rack
RackRack
Rack
 

Kürzlich hochgeladen

VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Christo Ananth
 

Kürzlich hochgeladen (20)

MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 

Wysiwig on Rails

  • 2. Hello! • timakin / @__timakin__ • Ruby / Node / Go • https://medium.com/@timakin • tech-savvy.hatenablog.com
  • 4.
  • 8. Wysiwyg Rails • CKE Editor • Squire • Froala Editor • Bootsy • Redactor • Medium-Editor
  • 10. CKE Editor • • WordPress • Rails Carrierwave/PaperClip • Plugin Rails config •
  • 14. Froala Editor • • • S3 ( or Froala Storage ) • input
  • 16. Bootsy • Rails i18n • Squire • Carrierwave bootstrap-wysihtml5
  • 18. Redactor • • Video insert (Embed tag ) / Table view / File upload •
  • 21. Wysiwyg Rails • CKE Editor • Squire • Froala Editor • Bootsy • Redactor • Medium-Editor
  • 22. Wysiwyg Rails • CKE Editor • Squire • Froala Editor • Bootsy • Redactor • Medium-Editor
  • 23. Wysiwyg Rails • CKE Editor • Squire • Froala Editor • Bootsy • Redactor • Medium-Editor
  • 25. Dante-Editor • Medium-Editor Medium • Image upload, video, social embed / • iframe url embedly • S3 API js • div value form hidden_field • gem
  • 26. image upload class ApiController < ApplicationController protect_from_forgery with: :null_session def upload_image s3 = Aws::S3::Resource.new(region: ENV['AWS_REGION'], access_key_id: ENV['AWS_ACCESS_KEY_ID'], secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']) case Rails.env when 'production' obj = s3.bucket(ENV['SACKET_FOG_PRODUCTION_DIRECTORY']).object("images/embedded/ #{SecureRandom.hex(8)}") when 'staging' obj = s3.bucket(ENV['SACKET_FOG_STAGING_DIRECTORY']).object("images/embedded/#{SecureRandom.hex(8)}") when 'development' obj = s3.bucket(ENV['SACKET_FOG_STAGING_DIRECTORY']).object("images/embedded/#{SecureRandom.hex(8)}") end obj.upload_file(params[:file].tempfile, acl: 'public-read') render json: { status: :ok, data: obj.public_url } end end
  • 27. form editor = new Dante.Editor( { el: "#editor", disable_title: true, upload_url: "/api/upload_image", base_widgets: ["uploader", "embed"], oembed_url: "http://api.embed.ly/1/oembed?key=hogehoge" } ); editor.start() $(document).ready(function(){ $("#editor").bind("input properchange", function(){ $("#text_" + $(this).attr("data-field-id")).val($(this).html()) }); });
  • 28. # var embedTemplate = function() { return "<figure contenteditable='false' class='graf--figure graf--iframe graf--first' name='504e' tabindex='0'> <div class='iframeContainer'> <iframe frameborder='0' width='700' height='393' data-media-id='' src='' data-height='480' data-width='854'> </iframe> </div> <figcaption contenteditable='true' data-default-value='Type caption for embed (optional)' class='imageCaption'> <a rel='nofollow' class='markup--anchor markup--figure-anchor' data-href='' href='' target='_blank'> </a> </ figcaption> </figure>"; }; var oembed_url = "http://api.embed.ly/1/oembed? key=c6fc4f62de674f8a8ee60a7cbea1e13d&url=";
  • 29. $(function(){ var node = $(".is-embedable"); var node_name = node.attr('name'); if (node.text()) { console.log(node.text()); return $.getJSON("" + oembed_url + (node.text())).success((function(_this) { return function(data) { var iframe_src, replaced_node, tmpl, url; var node = $("[name=" + node_name + "]"); node.hide(); iframe_src = $(data.html).prop("src"); tmpl = $(embedTemplate()); tmpl.attr("name", node.attr("name")); $(node).replaceWith(tmpl); replaced_node = $(".graf--iframe[name=" + (node.attr("name")) + "]"); replaced_node.find("iframe").attr("src", iframe_src); url = data.url || data.author_url; replaced_node.find(".markup--anchor").attr("href", url).text(url); }; })(this)).error((function(_this) { return function(res) { console.log(res); }; })(this)); } });