How to correctly compile a quarto website with nested folder structure? - quarto

I am experimenting with quarto to see how I can create a website. These are the steps that I have followed so far:
Open RStudio (RStudio Server 2022.02.0 Build 443)
Go to File > New Project... > New Directory > Quarto Website > type Directory name: > Create Project
Go to Build > Render Website
This works fine! However, when I try to add a section for blog, the website doesn't compile correctly. Here's what I did:
Create a blog folder under root
Create a file blog/index.qmd
Create a blog/posts folder
Create a blog/posts/test-post folder
Add files index.qmd and featured.jpg to blog/posts/test-post folder
Run this code in R console to add featured.jpg file:
download.file(
"https://upload.wikimedia.org/wikipedia/commons/3/3f/August_Macke_-_Three_girls_in_yellow_straw_hats_I_-_Google_Art_Project.jpg",
"blog/posts/test-post/featured.jpg"
)
Here are the contents of the blog/index.qmd file:
---
title: This is my blog.
listing:
contents: posts
type: default
---
Here are the contents of the blog/posts/test-post/index.qmd file:
---
title: My first blog post.
image: featured.jpg
---
Here are the contents of the _quarto.yml file:
project:
type: website
website:
title: "test-quarto-web"
navbar:
background: primary
left:
- href: index.qmd
text: Home
- about.qmd
- href: blog/index.qmd
text: Blog
format:
html:
theme: cosmo
css: styles.css
editor: visual
After I render the website and click on the Blog menu, this is what I see:
How can I fix this issue? I believe there is some problem with the file path, but I couldn't figure out how to fix this!

In my experience, this is frequently due to using an old version of Quarto. As Quarto is nearing release, there are improvements happening daily.
To install the latest version from Quarto, follow the instructions here. Use the "Latest Quarto version" tab.
If you install a new version, RStudio Desktop will recognize it.

Related

Drupal 9.4 is ignoring my translation info

The ...info.yml:
name: CEnquire
version: '9.x-1.3'
description: BlahBlah
package: CPackage
type: module
core_version_requirement: ^8 || ^9
interface translation project: cenquire
interface translation server pattern: modules/cpackage/cenquire/translation/%project-%version.%language.po
The language: Ukrainian (uk)
The .po file is named cenquire-9.x-1.3.uk.po and placed in proper directory
drush locale-check just ignores yml data: I don't get any Translation file not found errors. The site just has no data about any translation for the project exists. This is not a cache issue.
What am I doing wrong?

Convert a (LATEX) .tex file into .cls so it can be used in RMarkdown

I am interested in getting a LATEX template working in RMarkdown. In the past I have been able to get this to work by implementing a .cls document. But this is not available for this template.
In the main directory of the LATEX template I see a structure.tex and main.tex. Where structure.tex seems identical to previous .cls files I have used in the past.
Here is an example of how I implemented this in the past within an .Rmd document
---
title: My Title Goes Here
author: "Author Name"
output:
pdf_document:
keep_tex: yes
latex_engine: xelatex
documentclass: styles/thesis-umich3 #This is where the .cls document is stored
---
This causes me to get the following error claiming that /chaptermark is undefined.
`documentclass` searches specifically for a `.sty` file
Yet on line 173 I have:
\renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries\chaptername\ \thechapter.\ #1}{}} % Styling for the current chapter in the header
WHAT I HAVE TRIED
Calling a .tex document within in_header rather than in documentclass
---
title: "fNIRS Guide"
output:
pdf_document:
includes:
in_header: style/structure.tex
---
This causes the following error
tlmgr search --file --global "/numeric.dbx"
tlmgr search --file --global "/biblatex-dm.cfg"
! LaTeX Error: Command \chaptermark undefined.
Error: Failed to compile index.tex. See index.log for more info.
In addition: Warning messages:
1: In parse_packages(logfile, quiet = c(TRUE, FALSE, FALSE)) :
Failed to find a package that contains numeric.dbx
2: In parse_packages(logfile, quiet = c(TRUE, FALSE, FALSE)) :
Failed to find a package that contains biblatex-dm.cfg
Execution halted
I have also tried to call documentclass
---
title: "index"
output:
pdf_document:
keep_tex: yes
latex_engine: xelatex
documentclass: style/structureSavedAsCLS
---
This also fails to work. Does anyone have any suggestions on getting this template into a cls so I can use it in RMarkdown?
I understand this might be a very entry level question and I was not certain if it was moreso an RMarkdown or Latex question. Any input is greatly appreciated.
The particular error Command \chaptermark undefined. is caused by structure.tex expecting book.cls, while rmarkdown uses article.cls by default. You could try
---
title: "fNIRS Guide"
output:
pdf_document:
includes:
in_header: style/structure.tex
documentclass: book
---
But I expect other incompatibilities between the packages loaded in structure.tex and those loaded in the default template. The same type of problems might occur when converting the tex to a cls file. So instead I would suggest to combine main.tex and structure.tex to form a new template file. Quoting section 3.3.7.4 Custom templates from the rmarkdown book:
You can also replace the underlying Pandoc template using the template option:
---
title: "Habits"
output:
pdf_document:
template: quarterly-report.tex
---
Consult the documentation on Pandoc templates for additional details on templates. You can also study the default LaTeX template as an example.

how to deploy your dart app (using Web ui) without using Pub Deploy

What is the best strategy to deploy a Dart Web-ui app manually ?
pub deploy doesn't work for me and I have raised bug report. So am thinking what is the best way to manually deploy.
This is how I started:
1) From project root I compile the webui components (dwc.dart)
2) change directory to web/out then run dart2js
3) copy all .js files into that scripts/js public folder on server
4) copy appname.html to server changing css and script paths to option 3
5) Make sure dart.js is also in the same directory as item 3
this is as far as I got. So what else do I need to do ?
A few questions:
1) Do I manually change the file paths in the generated .js files to point to public folders on server for the files they are referencing and make sure those files are on server also ?
2) Do I need to copy all packages to server also ?
3) Any preferred file structure on server?
Any tips on this really appreciated.
Thanks.
I wrote a Grunt script for it (since I had no time to look up how to properly write code for Grunt, I did not share the code since it's a mess) but I basically do this:
compiling a list of files with dwc to a given out dir
compile it to javascript
clean up all non-deployable files
change some paths inside the HTML to match the server paths (for some reasons, this gets changed by the compilation process)
remove all packages except the ones I really need (JS interopt and browser)
Since I'm only using the JS version, I remove all dart packages. Since the paths inside the HTML files are up to you, you can already use a structure that suits you/your server.
I can provide you with a Grunt script to understand the order of tasks. Practically the order I use is this one:
Create the build directory. I usually use /build/web. I usually create these files (index.html, main.dart, /css and so on into the /web dir). I create the rest of components into /lib directory.
Compile the .dart file that contains the main() function ("main.dart" in my case for simpler projects) file to Javascript and put it into /build/web directory
Copy the other needed files and folders to the /build/web directory. Also, during this process you'll be copying the packages that your project needs. You'll see in the example provided below.
Remove all empty folders from the project
You can create a Grunt task to open the /index.html file in the browser once the building process has ended (I will not provide this example)
The structure of the dart test project:
testApp
- gruntfile.js
- package.js
/lib
/packages
/angular
/web
- index.html
- main.dart
/css
/img
So, the Grunt example script to cover steps from 1 - 4 looks like this (copy it to gruntfile.js):
module.exports = function (grunt) {
grunt.initConfig({
// 1.
// create build web directory
mkdir: {
build: {
options: {
create: ['build/web']
}
}
},
// 2.
// compile dart files
dart2js: {
options: {
// use this to fix a problem into dart2js node module. The module calls dart2js not dart2js.bat.
// this is needed for Windows. So use the path to your dart2js.bat file
"dart2js_bin": "C:/dart/dart-sdk/bin/dart2js.bat"
},
compile: {
files: {'build/web/main.dart.js': 'web/main.dart'}
}
},
// 3.
// copy all needed files, including all needed packages
// except the .dart files.
copy: {
build: {
files: [
{
expand: true,
src: [
'web/!(*.dart)',
'web/css/*.css',
'web/res/*.svg',
'web/packages/angular/**/!(*.dart)',
'web/packages/browser/**/!(*.dart)'
],
dest: 'build'
}
]
}
},
// 4.
// remove empty directories copied using the previous task
cleanempty: {
build: {
options: {
files: false
},
src: ['build/web/packages/**/*']
}
},
});
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.registerTask('default', [
'mkdir:build',
'dart2js',
'copy:build',
'cleanempty:build'
]);
};
So this is the Grunt script example.
Create a /gruntfile.js file into your project's root directory and copy/paste the script to it.
Create a /package.json file into your project's root directory and copy/paste the following script:
{
"name": "testApp",
"version": "0.0.1",
"description": "SomeDescriptionForTheTestApp",
"main": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "YourName",
"peerDependencies": {
"grunt-cli": "^0.1.13"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-cleanempty": "^1.0.3",
"grunt-contrib-copy": "^0.7.0",
"grunt-dart2js": "0.0.5",
"grunt-mkdir": "^0.1.2",
"matchdep": "^0.3.0"
}
}
Open Command Prompt in Windows, Terminal in Linux, navigate to your project's root directory and use this command:
npm install
Wait untill all Grunt modules needed will be downloaded to your local project. Once this is finished, issue this command in Command Prompt or Terminal:
node -e "require('grunt').cli()"
You can use this to initiate Grunt default task without having Grunt installed globally on your system.
Now, to know the exact build structure for your project (including the packages that the project needs), make a build using Pub Build. Then you will be able to instruct Grunt to create the same dir structure.
You can add other tasks (like minification) if you want.
Hope this will help you all to understand the process and get you started with a test app first. Add your comments to make this even better and simplify it even more.

jekyll not generating posts

I am using the bloggy gem to put a jekyll blog within my current rails app. Basically, you have a normal jekyll build but then you put your files in the config/jekyll directory and generate files into the public/blog directory.
However, when I run jekyll build, none of my posts are generated.
Here is the config file:
markdown: rdiscount
permalink: /:title.html
destination: ../../public/blog
exclude:
- Rakefile
- Gemfile
- .gitignore
Here is my directory structure within config/jekyll
./_config.yml
./_layouts
./_layouts/default.html
./_layouts/page.html
./_layouts/post.html
./_posts
./_posts/2013-06-07-dear-nsa.md
./_posts/2013-06-07-wut.markdown
./atom.xml
./css
./css/screen.css
./css/syntax.css
./index.html
And here is the generated directory structure with public/blog
./atom.xml
./css
./css/screen.css
./css/syntax.css
./index.html
A clue I've come up with: if I specify the source as the _posts, it will generate html versions of my posts into public/blog... but will not include the css or index page.

dajax.core ImportError at /No module named

I've installed dajaxice by this tutorial:
Copied folder "dajaxice" (from archive) to project folder.
Added all changes to setting.py & urls.py
Added next lines to template:
{% load dajaxice_templatetags %}
{% dajaxice_js_import %}
Created ajax.py in the project folder
Code from ajax.py:
from django.utils import simplejson
from dajaxice.core import dajaxice_functions
#dajaxice_register
def example1(request):
return simplejson.dumps({'message': 'hello world'})
dajaxice_functions.register(example1)
Code from .js file:
$("#id_submit").click(function(){
Dajaxice.theproject.example1(callback_example);
console.log("test clicked");
return false; });
When I restart the project in browser at first request I got:
ImportError at / No module named dajax.core
Request Method: GET
Request URL: http:// 127.0.0.1:8000/
Django Version: 1.4
Exception Type: ImportError
Exception Value: No module named dajax.core
Exception Location: C:\Python27\lib\importlib\__init__.py in import_module, line 37
Python Executable: C:\Python27\python.exe
Python Version: 2.7.3
Python Path: ['E:\\Projects\\py\\sites\\theproject', 'C:\\Windows\\system32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages', 'C:\\Python27\\lib\\site-packages\\PIL']
Server time: Fri, 3 Aug 2012 14:50:03 +0300
Any ideas?
load ajax.py in init.py(of main app)
Dajaxice is updating all the time. Make sure you have downloaded and installed the correct version of Dajax for the document you are reading. In your error message, it says, "No module named dajax.core", which is probably because you are using the wrong version.
And the current version of Dajaxice and Dajax can be found here:
https://pypi.python.org/pypi/django-dajax
https://pypi.python.org/pypi/django-dajaxice/0.5.5

Resources