I'm trying to use the app structure recommended by Angular folks: https://docs.google.com/document/d/1XXMvReO8-Awi1EZXAXS4PzDzdNvV6pGcuaF4Q9821Es/pub
It works great in development when all partials/templates are being loaded by relative path from a component's folder.
When I try to prepare my app for production and minify/concat all .js into one file I get 2 issues:
Output file still has relative path to my templates and partials, which are obviously not correct anymore.
Hot to control order of components/modules concatenation to guarantee that all component will be combined in correct order. (Can I achive this without tools like AMD/CommonJs)
some thoughts from me.
I have the following structure for my components:
├── src/scripts/components
│ ├── example
│ │ ├── example.js
│ │ ├── example.controllers.js
│ │ ├── example.directives.js
│ │ ├── example.filters.js
│ │ └── example.services.js
│ ├── address
│ │ ├── address.js
│ │ ├── address.controllers.js
│ │ └── address.filters.js
│ ├── costs
…
I use gulp to build the following structure:
├── inc/scripts/components
│ ├── example.js
│ ├── address.js
│ ├── costs.js
…
To get this structure I use gulp-flatten and gulp-tap. Here is my task:
// Components
gulp.task('scripts-components', function() {
return gulp.src(['src/scripts/components/**/*', '!**/*.md'])
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(flatten())
.pipe(tap(function (file) {
if (file.stat.isDirectory()) {
var name = file.relative + '.js';
return gulp.src([file.path + '/' + name, file.path + '/' + file.relative + '.*.js'])
.pipe(concat(name))
.pipe(gulp.dest('inc/scripts/components/'))
.pipe(uglify())
.pipe(rename({ suffix: '.min'}))
.pipe(gulp.dest('inc/scripts/components/'));
}
}));
});
May it's helpful for you or anyone other.
Ciao
Ralf
I found uglifying/minifying my AngularJS code caused a few issues, ng-min seemed to sort alot of these: https://www.npmjs.org/package/grunt-ngmin
Here's an snippet of my scripts tasks that build all my angular related code.
gulp.task('scritps', function () {
gulp.src(config.src.js + '/app.js')
.pipe(ngmin())
.pipe(uglify({ mangle: false }) : gutil.noop())
.pipe(gulp.dest(config.dest.js));
});
Related
I've got a project that looks something like this:
.
├── pyproject.toml
├── server.py
├── Shakefile.hs
└── ui
├── index.ts
└── Shakefile.hs
ui/Shakefile.hs contains something to the effect of:
import Development.Shake
main = shakeArgs shakeOptions $ do
want ["dist/index.js"]
"dist/index.js" %> \out -> do
need ["index.ts"]
cmd "tsc --outFile" [out]
and the root Shakefile.hs looks like:
import Development.Shake
main = shakeArgs shakeOptions $ do
want ["dist/server.tar"]
"dist/server.tar" %> \out -> do
need ["ui/dist/index.js", "server.py"]
cmd "tar cf" [out, "ui/dist/index.js", "server.py"]
Question: how should I model dist/server.tar's dependency on ui/dist/index.js?
My first guess was simply to add a rule specifying how to build ui/dist/index.html relative to the project root, with the action being to simply call shake (so that I don't have to keep the recipes in sync):
-- added to ./Shakefile.hs
"ui/dist/index.js" %> \_ -> do
cmd "stack exec shake -- -C ui dist/index.js"
BUT, considering the Shake paper cites Recursive Make Considered Harmful, I'm near certain this isn't the way to go.
Is there a way to import rules from another Shakefile? Can vanilla Haskell's import system be used to implement something like this? In either case, how could we (automatically?) translate rules and actions using paths relative to the child directory to be correct relative to the parent?
In general, I'm wondering about Shake's applicability to monorepos, and about the composability of different Shake-based build systems (i.e. Shakefiles from different internal projects).
Thanks for your consideration!
I attempted to replicate the directory structure in this tutorial by jerieljan. Unfortunately I seem to be getting the default PlantUML stylings. I have included the expected results vs. the actual results in screenshots below. I am using the Visual Studio Code extension by jebbs with preview. While the style sheets are too long to include here they can be found in the aforementioned linked tutorial. The diagram file is as follows:
# Sequence Diagram Example
#startuml
'General Defaults
!define BASEPATH ..
!include BASEPATH/globals/stylesheet.iuml
'Actor Definitions
autonumber 1 "0:"
title Sequence Diagram
A -> B: Perform Action
B --> A: (Response)
#enduml
The directory structure is the same as in the tutorial and is as follows:
$ tree
.
├── globals
│ ├── style-presets.iuml
│ └── stylesheet.iuml
└── diagrams
├── example-sequence.puml
├── etc...
Expected Diagram
Actual Diagram
I know that this is a broad questions so I'll try to set some boundaries to the domain of this question:
Let's assume that the data can arrive at any time from a source and the period is not fixed between data acquisition.
The data is represented using a generic index (time-based, length-based or index based)
The data payload could miss some "columns" (if we imagine a data chunk as a table)
An example of this scenario could be the following:
{ │ {
"timestamp": t3, │ "timestamp": t1, # t1 < t3
"temperature": 40, │ "temperature": 40,
┌───────────┐ "pressure": 1220 │ "color": "ffffff" ┌───────────┐
│ │ } │ } │ │
│ │ │ │
│ Source 1 ├─────────────────────────────────────────────────────────►│ │
│ │ │ │
│ │ │ │
└───────────┘ │ │
│ │ │
{ │ { │ │
"length_meters": l1,│ "length_meters": l2, │ │
┌───────────┐ "resistivity": 40 │ "resistivity": 40 │ │
│ │ } │ } │ │
│ │ │ MongoDB │
│ Source 2 ├─────────────────────────────────────────────────────────►│ │
│ │ │ │
│ │ │ │
└───────────┘ │ │
│ │
│ │
{ │ │
"index": 1, │ │
┌───────────┐ "description: "lorem" │ │
│ │ } │ │
│ │ │ │
│ Source 3 ├─────────────────────────────────────────────────────────►│ │
│ │ │ │
│ │ └───────────┘
└───────────┘
I've read the official documentation on the Bucket pattern in which they describe this technique which is, in my opinion, far from reality since in the example they suppose to store a single sensor data (temperature, in that case). Furthermore I don't like the solution since is repeating the column (temperature) for every sample of the sensors.
Is there any better and generic way to design the collection(s) to tackle such requirements which uses contained storage size and can enable good performance in terms of data querying?
Samples queries could be the following:
Return pressure and temperature between tx and ty.
Return the maximum temperature between tx and ty.
Return the minimum of resistivity between lx and ly.
Based on the sample data, the buckets could be also like this:
{
sensor_id: 12345,
start_date: ISODate("2019-01-31T10:00:00.000Z"),
end_date: ISODate("2019-01-31T10:59:59.000Z"),
timestamp: [
ISODate("2019-01-31T10:00:00.000Z"),
ISODate("2019-01-31T10:01:00.000Z"),
ISODate("2019-01-31T10:42:00.000Z")
],
temperature: [
40,
40,
42,
]
}
What do you mean by "good performance in terms of data querying"? It heavily depends ont the queries you like to run.
I'm trying to create a shortcode where I need to read a resource property. This is my shortcode lbimg.html:
{{ $img := $.Page.Resources.GetMatch (.Get "name")}}
{{$img.RelPermalink}}
This is how I use it:
{{< lbimg name="/images/test.png" >}}
This is what I'm getting when building the site:
failed to render shortcode "lbimg": failed to process shortcode: "path_to_blog/layouts/shortcodes/lbimg.html:2:6": execute of template failed: template: shortcodes/lbimg.html:2:6: executing "shortcodes/lbimg.html" at : nil pointer evaluating resource.Resource.RelPermalink
I don't understand what does that mean, why the resource is nil?
I'm using Hugo 0.59.1.
The content structure is as follows:
blog
├── content
│ └── post
│ └── test_post
│ ├── images
│ │ └── test.png
│ └── index.md
└── ...
Can you try this:
{{< lbimg name="images/test.png" >}}
My error was similar but my problem was not naming the page file index.md
I'm trying to write a shortcode for my hugo site that fetches the title parameter of page.
I have a directory structure like this:
content
├── workshops
│ ├── foo
│ │ └── _index.md
│ ├── bar.md
This works perfectly:
{{ with .Site.GetPage "home" "workshops/foo"}}
{{ .Params.Title }}
{{ end }}
And this one consistently comes up blank (even though there is a title in the markdown).
{{ with .Site.GetPage "home" "workshops/bar"}}
{{ .Params.Title }}
{{ end }}
My question is: How so I get the title of a standalone page?
I've tried a bunch of different combinations of things and I'm just not coming right. I've tried reading the docs and they are horribly convoluted on this point.
I have a solution! I wrote a little Python3.7 script to make directories and move and rename markdown files and just ran it over my entire contents directory. This solved my problem but is a bit of a hack...
import logging
import os
from pathlib import Path
def fixup(path):
location = Path(path)
assert location.is_dir(), location
for child in location.iterdir():
if child.is_dir():
fixup(child)
else:
fix_file(child)
def fix_file(file_path):
name = file_path.name
if not name.endswith(".md"):
# we only care about markdown files.
return
check_metadata(file_path)
if name.startswith("_index."):
# looks good
return
# make a directory with the same name as the file (without the extension)
suffix = ''.join(file_path.suffixes)
prefix = name[: -len(suffix)]
new_dir = file_path.parent / prefix
new_dir.mkdir()
new_path = new_dir / f"_index{suffix}"
file_path.rename(new_path)
def check_metadata(file_path):
""" given the path to a markdown file, make sure that the frontmatter includes
the required metadata
"""
# TODO
# required = ['title']
# allowed = ['pre', 'weight', 'ready']
if __name__ == '__main__':
fixup('content')
Two differences:
Use the global site variable
Just pass the page name as the argument
{{ with site.GetPage "workshops/bar" }}
{{ .Title }}
{{ end }}