-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Space-pen support #47
Comments
We could either |
If we are going to use |
$ = require('atom').$;
var clearRequire = require('clear-require');
var p = '/absolute/path/to/temp/file.coffee'; // Temp file path
clearRequire(p); // Clear from Node require cache
var dv = require(p); // Get the View module
var d = new dv(); // Create new View
// Check if it is an instance of a Space-pen View
if (d instanceof $) {
// Is Space-pen view
} |
Instead of using |
The issue with requiring the module from a temp directory is that the relative Apparently you can set |
|
Setting an environment variable is easy: process.env.ENV_VARIABLE However, we should revert afterwards. So be sure to store the previous You can append to an existing |
See http://nodejs.org/api/modules.html#modules_loading_from_the_global_folders |
So NODE_PATH is not working. # Patch the NODE_PATH
cd = path.dirname(filepath)
nodePath = process.env.NODE_PATH
deli = ":"
newNodePath = "#{nodePath}#{deli}#{cd}"
console.log newNodePath
process.env.NODE_PATH = newNodePath
View = null
try
View = require(info.path) # Get the View module
catch e
# Revert NODE_PATH
process.env.NODE_PATH = nodePath
return cb(e, null) Still cannot find modules. |
Going to try and play with |
|
Found out why require('module').Module._initPaths(); |
So that works if it is not a relative > process.env.NODE_PATH = "/Applications/Atom.app/Contents/Resources/app/exports:/Users/glavin/Documents/Project Dev/atom-preview/lib"
"/Applications/Atom.app/Contents/Resources/app/exports:/Users/glavin/Documents/Project Dev/atom-preview/lib"
> require('module').Module._initPaths();
> require('preview-view')
function PreviewView() {
this.hideViewPreview = __bind(this.hideViewPreview, this);
this.renderViewForPreview = __bind(this.renderViewForPreview, this);
this.renderPreviewWithRenderer = __bind(this.renderPreviewWithRenderer, this);
this.renderPreview = __bind(this.renderPreview, this);
this.handleTabChanges = __bind(this.handleTabChanges, this);
this.changeHandler = __bind(this.changeHandler, this);
var Analytics, buffer, editor, uuid;
buffer = new TextBuffer;
editor = new Editor({
buffer: buffer
});
PreviewView.__super__.constructor.call(this, editor);
this.addClass('preview-container');
editor.setText('');
this.editorContents = $('.editor-contents', this.element);
this.messageView = new PreviewMessageView();
this.showLoading();
this.optionsView = new OptionsView(this);
this.selectRendererView = new SelectRendererView(this);
this.htmlPreviewContainer = $$(function() {
return this.div((function(_this) {
return function() {
return _this.div("THIS IS A TEST");
};
})(this));
});
this.append(this.htmlPreviewContainer);
atom.workspaceView.on('pane-container:active-pane-item-changed', this.handleTabChanges);
atom.config.observe('preview.refreshDebouncePeriod', (function(_this) {
return function(wait) {
return _this.debouncedRenderPreview = _.debounce(_this.renderPreview.bind(_this), wait);
};
})(this));
Analytics = require('analytics-node');
this.analytics = new Analytics(analyticsWriteKey);
if (!atom.config.get('preview._analyticsUserId')) {
uuid = require('node-uuid');
atom.config.set('preview._analyticsUserId', uuid.v4());
}
atom.config.observe('preview._analyticsUserId', {}, (function(_this) {
return function(userId) {
return _this.analytics.identify({
userId: userId
});
};
})(this));
this.renderPreview();
} preview-view.coffee:27
> require('./preview-view')
Error: Cannot find module './preview-view' |
Still not working. Also tried editing the |
How about creating a temporary file in the same directory!? I'll try that now.. |
See #47. Start implementing SpacePen support.
To try out |
@ddavison have you had a chance to try the SpacePen preview? :) |
No I hadn't yet.. i still can't get it to trigger :P I opened up |
Oh sorry, I forgot to say in the above instructions: |
See https://github.com/atom/space-pen
Render from Spacepen source (JavaScript and CoffeeScript support) to an HTML preview of what it will look like.
Use the JSON editor (#36) as the
@content
params for rendering, defaulting to{}
.Blocked by #22 and #36.
The text was updated successfully, but these errors were encountered: