Skip to content

Commit

Permalink
added functionality that implements already existing content from ser…
Browse files Browse the repository at this point in the history
…ver, process it and then presents it to the UI
  • Loading branch information
brijeshb42 committed Aug 11, 2015
1 parent b648020 commit 28dbf6f
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 28 deletions.
2 changes: 1 addition & 1 deletion dist/legoblocks.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/legoblocks.embed.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/legoblocks.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/maps/legoblocks.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/maps/legoblocks.embed.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/maps/legoblocks.js.map

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,10 @@ gulp.task("usemin", ['less'], function() {
.pipe(gulp.dest('dist'));
});

gulp.task("default", ["usemin"]);
gulp.task("watch", ["usemin"], function() {
gulp.watch("src/js/*.js*", ["usemin"]);
gulp.watch("src/css/*.less", ["usemin"])
});

gulp.task("prod", ["usemin"]);
gulp.task("default", ["watch"]);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Legoblocks",
"version": "0.1.1",
"version": "0.1.2",
"description": "A block based rich text editor with support of Images, embeds( Youtube, twitter, etc)",
"main": "gulpfile.js",
"devDependencies": {
Expand Down
15 changes: 1 addition & 14 deletions src/js/block.embed.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
checkContent: function(ok) {
if(ok) {
this.props.onContentChanged(this.props.position, this.state.url);
} else if(this.props.content === this.state.url) {
} else {
this.setState({
loaded: false
Expand Down Expand Up @@ -110,17 +111,3 @@
window.LegoBlocks = APP;

})(window);

/*
vimeo: {
regex: /(?:http[s]?:\/\/)?(?:www.)?vimeo\.co(?:.+(?:\/)([^\/].*)+$)/,
html: "<iframe src=\"<%= protocol %>//player.vimeo.com/video/<%= remote_id %>?title=0&byline=0\" width=\"580\" height=\"320\" frameborder=\"0\"></iframe>"
},
youtube: {
regex: /^.*(?:(?:youtu\.be\/)|(?:youtube\.com)\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*)/,
html: "<iframe src=\"<%= protocol %>//www.youtube.com/embed/<%= remote_id %>\" width=\"580\" height=\"320\" frameborder=\"0\" allowfullscreen></iframe>"
}
*/

//React.render(<LegoBlocks.Instagram url="https://instagram.com/p/6H5rZHkOEF/?taken-by=thedesistuff" />, document.getElementById('editor-content'));
//React.render(<LegoBlocks.Blocks.Embed.React content="" />, document.getElementById('editor-content'));
2 changes: 1 addition & 1 deletion src/js/block.embed.youtube.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
);
}
return (
<div className="legob-embed">Invalid instagram URL.</div>
<div className="legob-embed">Invalid youtube URL.</div>
);
}
});
Expand Down
35 changes: 32 additions & 3 deletions src/js/components.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,39 @@
return initialState;
},

getDefaultProps: function() {
return {
blockUrl: ''
};
},

componentDidMount: function() {
if(this.props.blocks) {
this.setState({
blocks: this.props.blocks
var self = this;
if(this.props.blockUrl !== '') {
fetch(self.props.blockUrl, {
credentials: 'same-origin',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}).then(function(response) {
if (response.status >= 200 && response.status < 300) {
return response.json();
} else {
var error = new Error(response.statusText);
error.response = response;
throw error;
}
}).then(function(json) {
if(self.props.processData) {
self.setState({
blocks: self.props.processData(json)
});
} else {
console.warn('Provide a function to process blocks.');
}
}).catch(function(e) {
console.error(e);
})
}
},
Expand Down

0 comments on commit 28dbf6f

Please sign in to comment.