2017-07-13 05:02:21 +00:00
|
|
|
|
2016-11-02 03:27:51 +00:00
|
|
|
/*
|
|
|
|
* Mr. 4th Dimention - Allen Webster
|
|
|
|
*
|
|
|
|
* 25.02.2016
|
|
|
|
*
|
2017-07-10 22:34:13 +00:00
|
|
|
* Site generator for 4coder.
|
2016-11-02 03:27:51 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// TOP
|
|
|
|
|
2016-11-28 19:13:53 +00:00
|
|
|
#define STB_IMAGE_IMPLEMENTATION
|
|
|
|
#include "stb_image.h"
|
2016-12-08 17:16:50 +00:00
|
|
|
#define STB_IMAGE_RESIZE_IMPLEMENTATION
|
|
|
|
#include "stb_image_resize.h"
|
2016-12-14 16:09:54 +00:00
|
|
|
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
|
|
|
#include "stb_image_write.h"
|
2016-11-28 19:13:53 +00:00
|
|
|
|
2016-11-02 03:27:51 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2017-07-07 23:54:50 +00:00
|
|
|
#include "../4ed_defines.h"
|
|
|
|
#include "../meta/4ed_meta_defines.h"
|
2017-01-30 17:30:03 +00:00
|
|
|
|
2017-01-23 06:19:43 +00:00
|
|
|
#include "../4coder_API/version.h"
|
2017-01-07 02:59:55 +00:00
|
|
|
#define FSTRING_IMPLEMENTATION
|
2017-01-23 06:19:43 +00:00
|
|
|
#include "../4coder_lib/4coder_string.h"
|
|
|
|
#include "../4cpp/4cpp_lexer.h"
|
2016-11-28 19:13:53 +00:00
|
|
|
|
2017-07-10 14:51:19 +00:00
|
|
|
#define FTECH_FILE_MOVING_IMPLEMENTATION
|
|
|
|
#include "../meta/4ed_file_moving.h"
|
2017-07-09 04:28:33 +00:00
|
|
|
#include "../meta/4ed_meta_parser.cpp"
|
2017-07-10 14:51:19 +00:00
|
|
|
#include "../meta/4ed_meta_keywords.h"
|
2017-07-09 04:28:33 +00:00
|
|
|
#include "4ed_abstract_document.cpp"
|
2016-11-02 03:27:51 +00:00
|
|
|
|
2016-11-22 18:26:58 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2016-11-02 03:27:51 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Meta Parse Rules
|
|
|
|
//
|
|
|
|
|
2017-07-13 05:02:21 +00:00
|
|
|
internal void
|
2017-01-07 02:59:55 +00:00
|
|
|
print_function_body_code(String *out, Parse_Context *context, i32 start){
|
2016-11-02 03:27:51 +00:00
|
|
|
String pstr = {0}, lexeme = {0};
|
|
|
|
Cpp_Token *token = 0;
|
|
|
|
|
2017-01-07 02:59:55 +00:00
|
|
|
i32 do_print = 0;
|
|
|
|
i32 nest_level = 0;
|
|
|
|
i32 finish = 0;
|
|
|
|
i32 do_whitespace_print = 0;
|
2016-11-02 03:27:51 +00:00
|
|
|
for (; (token = get_token(context)) != 0; get_next_token(context)){
|
|
|
|
if (do_whitespace_print){
|
|
|
|
pstr = str_start_end(context->data, start, token->start);
|
2017-07-13 05:02:21 +00:00
|
|
|
append(out, pstr);
|
2016-11-02 03:27:51 +00:00
|
|
|
}
|
|
|
|
else{
|
2016-11-23 03:37:28 +00:00
|
|
|
do_whitespace_print = 1;
|
2016-11-02 03:27:51 +00:00
|
|
|
}
|
|
|
|
|
2016-11-23 03:37:28 +00:00
|
|
|
do_print = 1;
|
2016-11-02 03:27:51 +00:00
|
|
|
if (token->type == CPP_TOKEN_COMMENT){
|
|
|
|
lexeme = get_lexeme(*token, context->data);
|
|
|
|
if (check_and_fix_docs(&lexeme)){
|
2016-11-23 03:37:28 +00:00
|
|
|
do_print = 0;
|
2016-11-02 03:27:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (token->type == CPP_TOKEN_BRACE_OPEN){
|
|
|
|
++nest_level;
|
|
|
|
}
|
|
|
|
else if (token->type == CPP_TOKEN_BRACE_CLOSE){
|
|
|
|
--nest_level;
|
|
|
|
if (nest_level == 0){
|
2016-11-23 03:37:28 +00:00
|
|
|
finish = 1;
|
2016-11-02 03:27:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (do_print){
|
|
|
|
pstr = get_lexeme(*token, context->data);
|
2017-07-13 05:02:21 +00:00
|
|
|
append(out, pstr);
|
2016-11-02 03:27:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
start = token->start + token->size;
|
|
|
|
|
|
|
|
if (finish){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-12-14 16:09:54 +00:00
|
|
|
|
2017-07-13 05:02:21 +00:00
|
|
|
internal void
|
2017-07-10 14:51:19 +00:00
|
|
|
do_html_output(Document_System *doc_system, char *dst_directory, Abstract_Item *doc){
|
2017-07-10 17:05:30 +00:00
|
|
|
String out = make_string_cap(fm__push(10 << 20), 0, 10 << 20);
|
|
|
|
Assert(out.str != 0);
|
2016-11-24 06:02:18 +00:00
|
|
|
|
2017-07-10 17:05:30 +00:00
|
|
|
char doc_link[256];
|
|
|
|
if (doc_get_link_string(doc, doc_link, sizeof(doc_link))){
|
|
|
|
generate_document_html(&out, doc_system, doc);
|
|
|
|
char *name = fm_str(dst_directory, "/", doc_link);
|
2017-07-10 17:42:09 +00:00
|
|
|
fm_write_file(name, out.str, out.size);
|
|
|
|
out.size = 0;
|
2016-11-25 06:16:04 +00:00
|
|
|
}
|
2016-12-14 16:09:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO(allen): replace the documentation declaration system with a straight up enriched text system
|
2017-07-13 05:02:21 +00:00
|
|
|
internal Abstract_Item*
|
2017-07-10 14:51:19 +00:00
|
|
|
generate_4coder_docs(Document_System *doc_system, char *code_directory, char *src_directory){
|
|
|
|
Meta_Unit *custom_types_unit = fm_push_array(Meta_Unit, 1);
|
|
|
|
Meta_Unit *lexer_funcs_unit = fm_push_array(Meta_Unit, 1);
|
|
|
|
Meta_Unit *lexer_types_unit = fm_push_array(Meta_Unit, 1);
|
|
|
|
Meta_Unit *string_unit = fm_push_array(Meta_Unit, 1);
|
|
|
|
Meta_Unit *custom_funcs_unit = fm_push_array(Meta_Unit, 1);
|
2016-12-14 16:09:54 +00:00
|
|
|
|
2017-07-10 14:51:19 +00:00
|
|
|
Enriched_Text *introduction = fm_push_array(Enriched_Text, 1);
|
|
|
|
Enriched_Text *lexer_introduction = fm_push_array(Enriched_Text, 1);
|
2016-12-14 16:09:54 +00:00
|
|
|
|
2017-01-30 17:30:03 +00:00
|
|
|
// NOTE(allen): Parse the code.
|
2017-07-10 14:51:19 +00:00
|
|
|
*custom_types_unit = compile_meta_unit(code_directory, "4coder_API/types.h", ExpandArray(meta_keywords));
|
2017-01-30 17:30:03 +00:00
|
|
|
Assert(custom_types_unit->count != 0);
|
2016-12-14 16:09:54 +00:00
|
|
|
|
2017-07-10 14:51:19 +00:00
|
|
|
*lexer_funcs_unit = compile_meta_unit(code_directory, "4cpp/4cpp_lexer.h", ExpandArray(meta_keywords));
|
2017-01-30 17:30:03 +00:00
|
|
|
Assert(lexer_funcs_unit->count != 0);
|
2016-12-14 16:09:54 +00:00
|
|
|
|
2017-07-10 14:51:19 +00:00
|
|
|
*lexer_types_unit = compile_meta_unit(code_directory, "4cpp/4cpp_lexer_types.h", ExpandArray(meta_keywords));
|
2017-01-30 17:30:03 +00:00
|
|
|
Assert(lexer_types_unit->count != 0);
|
2016-12-14 16:09:54 +00:00
|
|
|
|
2017-07-10 14:51:19 +00:00
|
|
|
*string_unit = compile_meta_unit(code_directory, "string/internal_4coder_string.cpp", ExpandArray(meta_keywords));
|
2017-01-30 17:30:03 +00:00
|
|
|
Assert(string_unit->count != 0);
|
2016-12-14 16:09:54 +00:00
|
|
|
|
2017-07-10 14:51:19 +00:00
|
|
|
*custom_funcs_unit = compile_meta_unit(code_directory, "4ed_api_implementation.cpp", ExpandArray(meta_keywords));
|
2017-01-30 17:30:03 +00:00
|
|
|
Assert(custom_funcs_unit->count != 0);
|
2016-12-14 16:09:54 +00:00
|
|
|
|
|
|
|
// NOTE(allen): Compute and store variations of the custom function names
|
2017-07-10 14:51:19 +00:00
|
|
|
Alternate_Names_Array *custom_func_names = fm_push_array(Alternate_Names_Array, 1);
|
2017-07-09 04:28:33 +00:00
|
|
|
i32 name_count = custom_funcs_unit->set.count;
|
2017-07-10 14:51:19 +00:00
|
|
|
custom_func_names->names = fm_push_array(Alternate_Name, name_count);
|
2017-07-09 04:28:33 +00:00
|
|
|
memset(custom_func_names->names, 0, sizeof(*custom_func_names->names)*name_count);
|
2016-12-14 16:09:54 +00:00
|
|
|
|
2017-01-07 02:59:55 +00:00
|
|
|
for (i32 i = 0; i < custom_funcs_unit->set.count; ++i){
|
2016-12-14 16:09:54 +00:00
|
|
|
String name_string = custom_funcs_unit->set.items[i].name;
|
|
|
|
String *macro = &custom_func_names->names[i].macro;
|
|
|
|
String *public_name = &custom_func_names->names[i].public_name;
|
2016-11-22 18:26:58 +00:00
|
|
|
|
2017-07-10 14:51:19 +00:00
|
|
|
*macro = str_alloc(name_string.size+4);
|
2016-12-14 16:09:54 +00:00
|
|
|
to_upper_ss(macro, name_string);
|
|
|
|
append_ss(macro, make_lit_string("_SIG"));
|
2016-11-22 18:26:58 +00:00
|
|
|
|
2017-07-10 14:51:19 +00:00
|
|
|
*public_name = str_alloc(name_string.size);
|
2016-12-14 16:09:54 +00:00
|
|
|
to_lower_ss(public_name, name_string);
|
2016-11-22 18:26:58 +00:00
|
|
|
|
2017-07-10 14:51:19 +00:00
|
|
|
fm_align();
|
2016-12-14 16:09:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE(allen): Load enriched text materials
|
2017-07-10 14:51:19 +00:00
|
|
|
*introduction = load_enriched_text(src_directory, "introduction.txt");
|
|
|
|
*lexer_introduction = load_enriched_text(src_directory, "lexer_introduction.txt");
|
2016-12-14 16:09:54 +00:00
|
|
|
|
|
|
|
// NOTE(allen): Put together the abstract document
|
|
|
|
Abstract_Item *doc = begin_document_description(doc_system, "4coder API Docs", "custom_docs", 1);
|
|
|
|
|
|
|
|
add_table_of_contents(doc);
|
|
|
|
|
|
|
|
begin_section(doc, "Introduction", "introduction");
|
|
|
|
add_enriched_text(doc, introduction);
|
|
|
|
end_section(doc);
|
|
|
|
|
|
|
|
begin_section(doc, "4coder Systems", "4coder_systems");
|
|
|
|
add_todo(doc);
|
|
|
|
end_section(doc);
|
|
|
|
|
|
|
|
begin_section(doc, "Types and Functions", "types_and_functions");
|
|
|
|
{
|
|
|
|
begin_section(doc, "Function List", 0);
|
|
|
|
add_element_list(doc, custom_funcs_unit, custom_func_names, AltName_Public_Name);
|
2016-11-22 18:26:58 +00:00
|
|
|
end_section(doc);
|
2016-12-14 16:09:54 +00:00
|
|
|
begin_section(doc, "Type List", 0);
|
|
|
|
add_element_list(doc, custom_types_unit);
|
2016-11-22 18:26:58 +00:00
|
|
|
end_section(doc);
|
2016-12-14 16:09:54 +00:00
|
|
|
begin_section(doc, "Function Descriptions", 0);
|
|
|
|
add_full_elements(doc, custom_funcs_unit, custom_func_names, AltName_Public_Name);
|
2016-11-22 18:26:58 +00:00
|
|
|
end_section(doc);
|
2016-12-14 16:09:54 +00:00
|
|
|
begin_section(doc, "Type Descriptions", 0);
|
|
|
|
add_full_elements(doc, custom_types_unit);
|
2016-11-22 18:26:58 +00:00
|
|
|
end_section(doc);
|
2016-12-14 16:09:54 +00:00
|
|
|
}
|
|
|
|
end_section(doc);
|
|
|
|
|
|
|
|
begin_section(doc, "String Library", "string_library");
|
|
|
|
{
|
|
|
|
begin_section(doc, "String Library Intro", 0);
|
|
|
|
add_todo(doc);
|
|
|
|
end_section(doc);
|
|
|
|
begin_section(doc, "String Function List", 0);
|
|
|
|
add_element_list(doc, string_unit);
|
|
|
|
end_section(doc);
|
|
|
|
begin_section(doc, "String Function Descriptions", 0);
|
|
|
|
add_full_elements(doc, string_unit);
|
2016-11-22 18:26:58 +00:00
|
|
|
end_section(doc);
|
|
|
|
}
|
2016-12-14 16:09:54 +00:00
|
|
|
end_section(doc);
|
2016-11-22 18:26:58 +00:00
|
|
|
|
2016-12-14 16:09:54 +00:00
|
|
|
begin_section(doc, "Lexer Library", "lexer_library");
|
|
|
|
{
|
|
|
|
begin_section(doc, "Lexer Intro", 0);
|
|
|
|
add_enriched_text(doc, lexer_introduction);
|
|
|
|
end_section(doc);
|
|
|
|
begin_section(doc, "Lexer Function List", 0);
|
|
|
|
add_element_list(doc, lexer_funcs_unit);
|
|
|
|
end_section(doc);
|
|
|
|
begin_section(doc, "Lexer Type List", 0);
|
|
|
|
add_element_list(doc, lexer_types_unit);
|
|
|
|
end_section(doc);
|
|
|
|
begin_section(doc, "Lexer Function Descriptions", 0);
|
|
|
|
add_full_elements(doc, lexer_funcs_unit);
|
|
|
|
end_section(doc);
|
|
|
|
begin_section(doc, "Lexer Type Descriptions", 0);
|
|
|
|
add_full_elements(doc, lexer_types_unit);
|
|
|
|
end_section(doc);
|
2016-11-22 18:26:58 +00:00
|
|
|
}
|
2016-12-14 16:09:54 +00:00
|
|
|
end_section(doc);
|
2016-11-22 18:26:58 +00:00
|
|
|
|
2016-12-14 16:09:54 +00:00
|
|
|
end_document_description(doc);
|
|
|
|
|
|
|
|
return(doc);
|
|
|
|
}
|
2016-11-24 06:02:18 +00:00
|
|
|
|
2017-07-10 15:56:57 +00:00
|
|
|
internal Abstract_Item*
|
2017-07-10 22:47:12 +00:00
|
|
|
generate_page(Document_System *doc_system, char *code_directory, char *src_directory, char *source_text, char *big_title, char *small_name){
|
2017-07-10 15:56:57 +00:00
|
|
|
Enriched_Text *home = fm_push_array(Enriched_Text, 1);
|
|
|
|
*home = load_enriched_text(src_directory, source_text);
|
2016-12-14 16:09:54 +00:00
|
|
|
|
2017-07-10 15:56:57 +00:00
|
|
|
Abstract_Item *doc = begin_document_description(doc_system, big_title, small_name, 0);
|
2017-07-10 22:47:12 +00:00
|
|
|
if (doc != 0){
|
|
|
|
add_enriched_text(doc, home);
|
|
|
|
end_document_description(doc);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
fprintf(stdout, "warning: could not create document %s from file %s\n", small_name, source_text);
|
|
|
|
}
|
2016-12-14 16:09:54 +00:00
|
|
|
|
|
|
|
return(doc);
|
|
|
|
}
|
|
|
|
|
2017-07-13 05:02:21 +00:00
|
|
|
internal String
|
2017-07-10 14:51:19 +00:00
|
|
|
push_string(i32 size){
|
2016-12-14 16:09:54 +00:00
|
|
|
String str = {0};
|
|
|
|
str.memory_size = size;
|
2017-07-10 14:51:19 +00:00
|
|
|
str.str = fm_push_array(char, size);
|
|
|
|
fm_align();
|
2016-12-14 16:09:54 +00:00
|
|
|
return(str);
|
|
|
|
}
|
|
|
|
|
2017-07-13 05:02:21 +00:00
|
|
|
internal void
|
2017-07-10 14:51:19 +00:00
|
|
|
do_image_resize(char *src_file, char *dst_file, char *extension, i32 w, i32 h){
|
2017-07-10 15:56:57 +00:00
|
|
|
Temp temp = fm_begin_temp();
|
|
|
|
|
2017-01-07 02:59:55 +00:00
|
|
|
i32 x = 0, y = 0, channels = 0;
|
2016-12-14 16:09:54 +00:00
|
|
|
stbi_uc *image = stbi_load(src_file, &x, &y, &channels, 0);
|
2017-07-13 05:02:21 +00:00
|
|
|
if (image != 0){
|
|
|
|
stbi_uc *resized_image = fm_push_array(stbi_uc, w*h*channels);
|
|
|
|
stbir_resize_uint8(image, x, y, x*channels, resized_image, w, h, w*channels, channels);
|
|
|
|
|
|
|
|
if (match_cc(extension, "png")){
|
|
|
|
stbi_write_png(dst_file, w, h, channels, resized_image, w*channels);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(image);
|
2016-12-08 17:16:50 +00:00
|
|
|
}
|
2017-07-13 05:02:21 +00:00
|
|
|
|
2017-07-10 15:56:57 +00:00
|
|
|
fm_end_temp(temp);
|
2016-12-14 16:09:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-13 05:02:21 +00:00
|
|
|
internal void
|
2016-11-28 19:13:53 +00:00
|
|
|
generate_site(char *code_directory, char *asset_directory, char *src_directory, char *dst_directory){
|
2017-07-10 14:51:19 +00:00
|
|
|
Document_System doc_system = create_document_system();
|
2016-12-08 17:16:50 +00:00
|
|
|
|
2017-03-30 23:42:26 +00:00
|
|
|
struct Site_Asset{
|
|
|
|
char *filename;
|
|
|
|
char *extension;
|
|
|
|
char *name;
|
|
|
|
u32 type;
|
|
|
|
};
|
|
|
|
enum Site_Asset_Type{
|
|
|
|
SiteAsset_None,
|
|
|
|
SiteAsset_Generic,
|
|
|
|
SiteAsset_Image,
|
|
|
|
};
|
|
|
|
|
|
|
|
Site_Asset asset_list[] = {
|
2017-07-13 05:02:21 +00:00
|
|
|
{"4coder_logo_low_green.png", "png", "4coder_logo", SiteAsset_Image },
|
|
|
|
{"screen_1.png", "png", "screen_1", SiteAsset_Image },
|
|
|
|
{"screen_2.png", "png", "screen_2", SiteAsset_Image },
|
|
|
|
{"screen_3.png", "png", "screen_3", SiteAsset_Image },
|
|
|
|
{"4coder_icon.ico", "ico", "4coder_icon", SiteAsset_Generic },
|
2017-03-30 23:42:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
for (u32 i = 0; i < ArrayCount(asset_list); ++i){
|
|
|
|
Site_Asset *asset = &asset_list[i];
|
|
|
|
|
2017-07-10 15:56:57 +00:00
|
|
|
char *name = fm_str(asset_directory, "/", asset->filename);
|
2017-03-30 23:42:26 +00:00
|
|
|
|
|
|
|
switch (asset_list[i].type){
|
|
|
|
case SiteAsset_Generic:
|
|
|
|
{
|
2017-07-10 15:56:57 +00:00
|
|
|
add_generic_file(&doc_system, name, asset->extension, asset->name);
|
2017-03-30 23:42:26 +00:00
|
|
|
}break;
|
|
|
|
|
|
|
|
case SiteAsset_Image:
|
|
|
|
{
|
2017-07-10 15:56:57 +00:00
|
|
|
add_image_description(&doc_system, name, asset->extension, asset->name);
|
2017-03-30 23:42:26 +00:00
|
|
|
}break;
|
|
|
|
|
|
|
|
default: InvalidCodePath;
|
|
|
|
}
|
|
|
|
}
|
2016-11-24 06:02:18 +00:00
|
|
|
|
2017-07-10 14:51:19 +00:00
|
|
|
generate_4coder_docs(&doc_system, code_directory, src_directory);
|
2017-07-10 15:56:57 +00:00
|
|
|
|
2017-07-10 22:47:12 +00:00
|
|
|
char *cdir = code_directory;
|
|
|
|
char *sdir = src_directory;
|
|
|
|
Document_System *docs = &doc_system;
|
|
|
|
|
|
|
|
// TODO(allen): From the text file get the "Big Title" and "smallname".
|
|
|
|
generate_page(docs, cdir, sdir, "home.txt" , "4coder Home" , "home" );
|
|
|
|
generate_page(docs, cdir, sdir, "docs.txt" , "4coder API Docs" , "custom_docs_2" );
|
|
|
|
generate_page(docs, cdir, sdir, "feature_list.txt", "4coder Feature List", "features" );
|
|
|
|
generate_page(docs, cdir, sdir, "binding_list.txt", "4coder Binding List", "bindings" );
|
|
|
|
generate_page(docs, cdir, sdir, "roadmap.txt" , "4coder Roadmap" , "roadmap" );
|
|
|
|
generate_page(docs, cdir, sdir, "tutorials.txt" , "4coder Tutorials" , "tutorials" );
|
2016-11-28 19:13:53 +00:00
|
|
|
|
|
|
|
for (Basic_Node *node = doc_system.doc_list.head;
|
2016-11-25 06:16:04 +00:00
|
|
|
node != 0;
|
|
|
|
node = node->next){
|
2016-11-28 19:13:53 +00:00
|
|
|
Abstract_Item *doc = NodeGetData(node, Abstract_Item);
|
2017-07-10 14:51:19 +00:00
|
|
|
Assert(doc->item_type == ItemType_Document);
|
2017-07-13 05:02:21 +00:00
|
|
|
do_html_output(&doc_system, dst_directory, doc);
|
2016-11-25 06:16:04 +00:00
|
|
|
}
|
2016-12-08 17:16:50 +00:00
|
|
|
|
|
|
|
for (Basic_Node *node = doc_system.file_list.head;
|
|
|
|
node != 0;
|
|
|
|
node = node->next){
|
|
|
|
Abstract_Item *file = NodeGetData(node, Abstract_Item);
|
2017-07-10 14:51:19 +00:00
|
|
|
Assert(file->item_type == ItemType_GenericFile);
|
2016-12-08 17:16:50 +00:00
|
|
|
|
2017-07-10 14:51:19 +00:00
|
|
|
char *file_name = fm_str(file->name, ".", file->extension);
|
|
|
|
fm_copy_file(fm_str(file_name), fm_str(dst_directory, "/", file_name));
|
2016-12-08 17:16:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (Basic_Node *node = doc_system.img_list.head;
|
|
|
|
node != 0;
|
|
|
|
node = node->next){
|
|
|
|
Abstract_Item *img = NodeGetData(node, Abstract_Item);
|
2017-07-10 14:51:19 +00:00
|
|
|
Assert(img->item_type == ItemType_Image);
|
2016-12-08 17:16:50 +00:00
|
|
|
|
|
|
|
for (Basic_Node *node = img->img_instantiations.head;
|
|
|
|
node != 0;
|
|
|
|
node = node->next){
|
|
|
|
Image_Instantiation *inst = NodeGetData(node, Image_Instantiation);
|
|
|
|
|
2017-07-10 15:56:57 +00:00
|
|
|
char img_link[256];
|
|
|
|
if (img_get_link_string(img, img_link, sizeof(img_link), inst->w, inst->h)){
|
|
|
|
char *dest_file = fm_str(dst_directory, "/", img_link);
|
|
|
|
do_image_resize(img->source_file, dest_file, img->extension, inst->w, inst->h);
|
2016-12-08 17:16:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-11-02 03:27:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv){
|
2017-01-30 17:30:03 +00:00
|
|
|
META_BEGIN();
|
2017-07-10 14:51:19 +00:00
|
|
|
fm_init_system();
|
2017-01-30 17:30:03 +00:00
|
|
|
|
2016-11-28 19:13:53 +00:00
|
|
|
if (argc == 5){
|
|
|
|
generate_site(argv[1], argv[2], argv[3], argv[4]);
|
2016-11-02 03:27:51 +00:00
|
|
|
}
|
2017-01-30 17:30:03 +00:00
|
|
|
|
|
|
|
META_FINISH();
|
2016-11-02 03:27:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// BOTTOM
|
|
|
|
|