middleman console: how to use it? - middleman

I would like to know how to use middleman console. Is it a simple irb? What can I do with it that differs from the simple irb?
middleman console [options] # Start an interactive console in the cont...
I have some articles and I try to do Article.all but I had this following error:
NameError: uninitialized constant Middleman::Application::MiddlemanApplication1::Article
from (irb#1):1
and I also have local-data /data/friends.json but Friend.all output error too.
{
"friends": [
"Tom",
"Dick",
"Harry"
]
}
I saw that Symbol.all_symbols output a lots of middleman variable and functions but I don't really know how to use the middleman console.

Oh man, I just spend a few hours trying to solve something that would have gone a lot faster if I had known that there was a middleman console!
I was trying to build the next/back logic for going through articles on my blog. There's a chronological thing, but I wanted to also be able to go back and forth on tags. There are a few that are tagged both "ruby" and (say) "rails", and "the next" for both tags was the same I wanted to list it together under both the tags.
The main problem was that I didn't know what sorts of things were available to me in the templates file. When you startup middleman console it loads up the configuration of your site so then you can start poking around.
$ bundle exec irb
2.0.0-p481 :001 > blog
NameError: undefined local variable or method `blog' for main:Object
from (irb):1
2.0.0-p481 :002 > exit
$ middleman console
== LiveReload is waiting for a browser to connect
2.0.0-p481 :001 > blog
=> #<Middleman::Blog::BlogData: [#<Middleman::Blog::BlogArticle: {"title"=>"Emb
etc.
What middleman console does is load up the middleman environment, and then lets you call methods on the current Middleman::Application object. If you are using a middleman extension and they've defined helpers, you can get to them here and start poking around.
Handy things:
config is the middleman config object.
data is the middleman data object, from the data directory
blog is the blog config, if you are using middleman-blog
drafts are the draft articles, if you are using middleman-blog-drafts

Related

Adobe analytics with vue js adding external script

Im struggling to add adobe analytics external scripts to my Vue js project. The client uses Adobe analytics and im battling to add it to the project without the project complaining.
The external adobe script looks like the following:
//assets.adobedtm.com/file.min.js with async
Then it is required that you end it by adding the following just before the closing body tag:
<script type="text/javascript">_satellite.pageBottom();</script>
When the project starts it complains in console that $ is not defined because it is defined in webpack when i start the project and im guessing its not finding the alias.
This is the error:
VM29714:3 Uncaught ReferenceError: $ is not defined
Then further down it complains that it doesnt know what _satellite is:
login:54 Uncaught ReferenceError: _satellite is not defined
I just need the scripts and satellite close to be added to the project, the rest will work once these are added.
Ive tried added the scripts by injecting them into the head tag on runtime but that also doesnt work.
If you are implementing Adobe DTM, you cannot inject the header script dynamically. It must be placed directly on the page without async or deferred attributes.
If you are implementing Adobe Launch, you can inject the header script dynamically and asynchronously. And if you do this, you do not include the footer (_satellite.pageBottom()) code.
Your script example isn't explicit, but the .min portion implies you are using Adobe Launch.
VM29714:3 Uncaught ReferenceError: $ is not defined
This is not directly related to either Adobe DTM or Launch. You may possibly have some other script or code block deployed inside the DTM or Launch interface that references $, but that's a separate issue to work out. Yes, it may be coming from a DTM or Launch script according to the js console, but keep in mind that DTM/Launch is a tag manager. It hosts and deploys other tags/scripts. So you need to do some digging to see which tag/script from which Rule references it. Start by looking at the stack trace to find out where it's coming from.

I am getting a "Bad response from Chimp Server" in my console when trying to run a meteor app with velocity/cucumber testing on it

The error is not in my regular console, it's in my tail -f console. It won't run the tests at all. In my localhost:3000 velocity sidebar it also says chimp server error. I am not sure how to fix this, I am very new to velocity and cucumber so it could be a stupid mistake, but I couldn't find any information on this error anywhere.
could you provide us with the whole meteor log and also cucumber log? If possible - please do meteor reset first (be aware though that this will clean up your local mongodb, if you want to avoid that, at least clean the cucumber log - echo '' > filePath will work )
I ran into the same problem yesterday while trying to follow Josh Owen's now outdated cucumber tutorial. The error was coming from with the step definition file while not wrapping module.exports in a function like this:
(function() {
module.exports = function() {
// ...
}
});
It could also be that your test directory and files aren't structured correctly in your app.
It should look like this:
app/
tests/
cucumber/
features/
step_definitions/
my_steps.js
my_feature.feature
fixtures/
my_fixture.js
Let me know if that makes a difference. Also, this is a good place to start with velocity/cucumber: http://www.mhurwi.com/a-basic-cucumber-meteor-tutorial/
It's very basic but there isn't much out there for learning testing with Meteor.

How to troubleshoot broken Rails logger (not accepting log_tags)?

I've moved a Rails 3.2.5 app from Heroku to a VPS and while the app was working beautifully on Heroku in terms of the log drain output, unfortunately all log output on the VPS and even running locally lacks timestamps or any other tags I'd like to prepend.
After attempting to create a fresh test app and including the following one of the config/envrionments or config/application.rb I've found that it prepends the indicated tags:
config.log_tags = [:uuid, :remote_ip, lambda { |req| Time.now }]
Notwithstanding, I've tried everything I can think of so far from combing through the app gems to grepping everything for any occurrence of "log" within the config and lib folders and subfolders (such as initializers).
I don't know, if somehow the Rails logger may be disabled, how can I find this out? Or what else could be going on here? Or what should I look for precisely?... Or should I attempt to force Rails logger and, if so, where & what should I insert Rails logger reset code to find out in an attempt to isolate where during system init the problem is occurring?
I had the same issue, you probably need to use ActiveSupport::TaggedLogging.
config.logger = ActiveSupport::TaggedLogging.new(Logger.new($stdout))

Heroku + Haml Problems

I am having issues with Heroku and Haml, I am able to run my app on localhost no problems, all test pass to, however when I go to run it on Heroku I get the following error:
We're sorry, but something went wrong.
We've been notified about this issue and we'll take a look at it shortly.
I read another post on Stackoeverflow that basically said to add a .gems file and add:
haml --version '>= 2.2.0'
I did that and I'm still having the same problem, so I'm wondering what I am doing wrong.
Update: I fixed that problem had to do with cache - and Heroku being read-only however now the theme I've selected via web-app does not load up on the Heroku page it shows up on local host however correctly. I looked at the log file for Heroku and it doesn't show any errors, so is it another permission issue?
Here is the log file - https://gist.github.com/1173667
Thanks,
Looks like your stylesheets are not included as part of the layout.
Assuming your stylesheet is available as public/stylesheets/styles.css, try adding the following line inside the head tag in application.html.haml
= stylesheet_link_tag 'styles.css'
That should resolve the theming issue. If not, post the code in application.html.haml
UPDATE:
From the logs, looks like you have two layouts: layouts/sign and layout/application. If they are there for a reason, you need to address that.
Else, change your home controller to render the new layout:
class HomeController < ApplicationController
layout "sign"
end

Multiple public folders, single rails installation

I have a rails application I would like to use for multiple sites, each with different designs.
I would like to change the rails installation /public directory to something else (dynamically eventually). However, I have run into a problem (bug?) changing directories...
In my application.rb file I change the paths.public path to something other than "public" (let's say "site_one"). Here is the code:
puts paths.public.paths
paths.public = "site_one"
puts paths.public.paths
The two "puts" commands are for debugging. Now run "rails s" and you will see:
/home/macklin/app/public
/home/macklin/app/site_one
This verifies the path is changed correctly. However, shortly afterward, rails throws the following error (let me know if you need the full trace):
Exiting
/usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/paths.rb:16:in `method_missing': undefined method `javascripts' for #<Rails::Paths::Path:0x7f422bd76f58> (NoMethodError) from /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_controller/railtie.rb:47
My guess is it cannot find the javascripts directory even though it is clearly sitting in the "site_one" folder.
Does anyone know why I am getting this?
I know this question is pretty old, but I think I found an answer for this in Rails 4.2.
You just simply have to put this line in your config/application.rb:
middleware.use ::ActionDispatch::Static, "#{Rails.root}/another_public_folder_name", index: 'index', headers: config.static_cache_control
This makes all files in /another_public_folder_name to be served by Rails.
This is the way Rails use to setup the standard /public folder. I found it checking the sources:
https://github.com/rails/rails/blob/52ce6ece8c8f74064bb64e0a0b1ddd83092718e1/railties/lib/rails/application/default_middleware_stack.rb#L24
Duh. Just add 2 more rules for stylesheets and javascripts (I guess they get wiped when you change the parent path)
paths.public.stylesheets = "site_one/stylesheets"
paths.public.javascripts = "site_one/javascripts"