Difference between revisions of "Truxton url create"

From truxwiki.com
Jump to navigation Jump to search
(Created page with "This creates an object you can use to record a website visit in Truxton. This adds records to the <code><nowiki>[</nowiki>WebsiteVisit<nowiki>]</nowiki>...")
 
 
(3 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
=Syntax=
 
=Syntax=
 
<source lang="C">
 
<source lang="C">
uint64_t truxton_url_create(uint64_t truxton_handle);
+
uint64_t truxton_url_create( uint64_t truxton_handle );
 
</source>
 
</source>
  
 
=Parameters=
 
=Parameters=
 
==<code>truxton_handle</code>==
 
==<code>truxton_handle</code>==
The Truxton instance this media will belong.
+
The Truxton instance this URL will belong.
 
This handle comes from calling <code>[[truxton_create]]()</code>.
 
This handle comes from calling <code>[[truxton_create]]()</code>.
  
Line 16: Line 16:
  
 
=Sample=
 
=Sample=
The following will set the primary photograph of the media.
 
This establishes the relationship that A is the primary photograph of B.
 
Specifically, <code>child_file</code> is the primary photograph of <code>media</code>.
 
 
<source lang="C" highlight="9">
 
<source lang="C" highlight="9">
void set_primary_photo( uint64_t truxton, uint64_t media, uint64_t child_file )
+
void add_home_url( uint64_t truxton, uint64_t media, uint64_t child_file, char const * url_address, uint64_t when )
 
{
 
{
 
   char media_id[ 65 ];
 
   char media_id[ 65 ];
Line 28: Line 25:
 
   truxton_child_file_get_id( child_file, file_id, sizeof( file_id ) );
 
   truxton_child_file_get_id( child_file, file_id, sizeof( file_id ) );
  
   uint64_t relation = truxton_relation_create( truxton );
+
   uint64_t url = truxton_url_create( truxton );
  
   // Now tell Truxton that child_file (A object) is the primary photo of media (B object)
+
   truxton_url_set_account( url, "admin" );
   truxton_relation_set_relation( relation, RELATION_PRIMARY_PHOTO );
+
   truxton_url_set_account_offset( url, -1 );
 
+
   truxton_url_set_file_id( url, file_id );
   // Set the A object, A is a file
+
   truxton_url_set_media_id( url, media_id );
   truxton_relation_set_a_id( relation, file_id );
+
   truxton_url_set_format( url, URL_FORMAT_ASCII );
   truxton_relation_set_a_type( relation, OBJECT_TYPE_FILE );
+
   truxton_url_set_local_filename( url, "document.htm" );
 
+
   truxton_url_set_method( url, URL_METHOD_TYPE_USER_TYPED_IT_IN );
   // Set the B object, B is a piece of media
+
   truxton_url_set_type( url, URL_TYPE_CHROME_HISTORY );
   truxton_relation_set_b_id( relation, media_id );
+
   truxton_url_set_url( url, url_address );
   truxton_relation_set_b_type( relation, OBJECT_TYPE_MEDIA );
+
   truxton_url_set_url_offset( url, -1 );
 
+
   truxton_url_set_when( url, when );
   // Set the source object, source is a piece of media
 
   truxton_relation_set_source_id( relation, media_id );
 
   truxton_relation_set_source_type( relation, OBJECT_TYPE_MEDIA );
 
  
 
   // Commit the data to the database
 
   // Commit the data to the database
   truxton_relation_save( relation );
+
   truxton_url_save( url );
   truxton_relation_destroy( relation );
+
   truxton_url_destroy( url );
 
}
 
}
 
</source>
 
</source>

Latest revision as of 18:02, 15 February 2021

This creates an object you can use to record a website visit in Truxton. This adds records to the [WebsiteVisit] table.

Syntax

uint64_t truxton_url_create( uint64_t truxton_handle );

Parameters

truxton_handle

The Truxton instance this URL will belong. This handle comes from calling truxton_create().

Return value

A handle to a URL object.

Sample

void add_home_url( uint64_t truxton, uint64_t media, uint64_t child_file, char const * url_address, uint64_t when )
{
   char media_id[ 65 ];
   char file_id[ 65 ];
   
   truxton_media_get_id( media, media_id, sizeof( media_id ) );
   truxton_child_file_get_id( child_file, file_id, sizeof( file_id ) );

   uint64_t url = truxton_url_create( truxton );

   truxton_url_set_account( url, "admin" );
   truxton_url_set_account_offset( url, -1 );
   truxton_url_set_file_id( url, file_id );
   truxton_url_set_media_id( url, media_id );
   truxton_url_set_format( url, URL_FORMAT_ASCII );
   truxton_url_set_local_filename( url, "document.htm" );
   truxton_url_set_method( url, URL_METHOD_TYPE_USER_TYPED_IT_IN );
   truxton_url_set_type( url, URL_TYPE_CHROME_HISTORY );
   truxton_url_set_url( url, url_address );
   truxton_url_set_url_offset( url, -1 );
   truxton_url_set_when( url, when );

   // Commit the data to the database
   truxton_url_save( url );
   truxton_url_destroy( url );
}