mirror of
https://github.com/tonytins/staggerpost.git
synced 2025-03-25 02:39:12 +00:00
Fixed Not Exporting to the Proper User Directory
- Removed new line when choosing a topic - Renamed newscycle.json to example.json in config - Changed path to "/" in config - If "/" is present in config, return the absolute current directory
This commit is contained in:
parent
188318c724
commit
14537bba03
6 changed files with 37 additions and 18 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -546,4 +546,4 @@ FodyWeavers.xsd
|
|||
.idea/**
|
||||
*.txt
|
||||
*.toml
|
||||
schedule.json
|
||||
example.json
|
|
@ -48,9 +48,9 @@ internal static class Export
|
|||
public static void ToJSON(List<String> storeTimes, string cfgPath)
|
||||
{
|
||||
// File directory is used for file location set in config
|
||||
var outputDir = Directory.GetCurrentDirectory();
|
||||
var topics = new List<string>();
|
||||
var config = GetConfig(cfgPath);
|
||||
var outputDir = Tracer.OutputDirectory(config.Path!);
|
||||
var outputFile = config.File;
|
||||
var filePath = Path.Combine(outputDir, outputFile!);
|
||||
var chosenTopic = "";
|
||||
|
|
|
@ -37,13 +37,11 @@ internal static class Interactive
|
|||
numOfTopics++;
|
||||
var title = community.Trim();
|
||||
topicDict.Add(numOfTopics, title);
|
||||
userChoices.Add(
|
||||
$"{Environment.NewLine}{numOfTopics} {title.TrimEnd(new char[] { ',' })}"
|
||||
);
|
||||
userChoices.Add($"{Environment.NewLine}{numOfTopics} {title}");
|
||||
}
|
||||
|
||||
var topicSelect = string.Join(", ", userChoices.ToArray());
|
||||
Console.WriteLine($"{Environment.NewLine}Choose a Topic{Environment.NewLine}{topicSelect}");
|
||||
Console.WriteLine($"Choose a Topic{Environment.NewLine}{topicSelect}");
|
||||
var input = Console.ReadLine();
|
||||
|
||||
// Attempt to parse a number.
|
||||
|
|
20
README.md
20
README.md
|
@ -1,8 +1,8 @@
|
|||
# StaggerPost
|
||||
# Stagger Post
|
||||
|
||||
This is a very simple console application that suggests a list of times to post news articles within a randomized 2-3 hour and 30-minute delay to avoid conflicts. This keeps thing flowing at an organic and slow pace.
|
||||
|
||||
It is not recommended for use with hot topics. Instead, you should focus on overlooked foreign affairs, local news or op-eds. Of course, this is just covering general news.
|
||||
It is not recommended for use with breaking news, of course. Instead, you should focus on overlooked local news or op-eds. Of course, this is just covering general news. It is really good niche communities.
|
||||
|
||||
## Exporting
|
||||
|
||||
|
@ -16,15 +16,15 @@ An optional ``config.toml`` file allows for further customization of file name,
|
|||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"topic": "Games",
|
||||
"date": "3/16/2025",
|
||||
{
|
||||
"community": "games@lemmy.world",
|
||||
"date": "3/22/2025",
|
||||
"times": [
|
||||
"11:41 AM",
|
||||
"2:05 PM",
|
||||
"5:05 PM",
|
||||
"8:18 PM",
|
||||
"11:02 PM"
|
||||
"1:34 PM",
|
||||
"3:03 PM",
|
||||
"5:27 PM",
|
||||
"9:13 PM",
|
||||
"11:37 PM"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
21
Tracer.cs
21
Tracer.cs
|
@ -63,4 +63,25 @@ internal static class Tracer
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the appropriate output directory based on the given directory path.
|
||||
/// In DEBUG mode, it always returns the current working directory.
|
||||
/// In release mode, it returns the provided directory unless it contains a '/', in which case it defaults to the current directory.
|
||||
/// </summary>
|
||||
/// <param name="dir">The directory path to evaluate.</param>
|
||||
/// <returns>The resolved output directory as a string.</returns>
|
||||
internal static string OutputDirectory(string dir)
|
||||
{
|
||||
var curDir = Directory.GetCurrentDirectory();
|
||||
|
||||
#if DEBUG
|
||||
return curDir;
|
||||
#else
|
||||
if (dir.Contains("/"))
|
||||
return curDir;
|
||||
|
||||
return dir;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
path = "/home/tonytins/Documents/"
|
||||
file = "newscycle.json"
|
||||
path = "/"
|
||||
file = "example.json"
|
||||
communities = [
|
||||
"Games",
|
||||
"News",
|
||||
|
|
Loading…
Add table
Reference in a new issue